I have got the following Map Structure
{CDetails=[{"collegeName":"Peters Stanford","collegeLoc":"UK"},{}]}
I am trying to get the collegeLoc value from the above mentioned structure
This is what i tried
public static void main(String[] args) {
Map < String, Object > empMap = new HashMap < > ();
JSONObject collegeNameJsonObj = new JSONObject();
collegeNameJsonObj.put("collegeName", "Peters Stanford");
JSONObject collegeIdJsonObj = new JSONObject();
collegeNameJsonObj.put("collegeLoc", "UK");
JSONArray jsonArray = new JSONArray();
jsonArray.add(collegeNameJsonObj);
jsonArray.add(collegeIdJsonObj);
empMap.put("CDetails", jsonArray);
System.out.println(empMap.entrySet().stream().filter(map->map.getKey().equals("CDetails")).map(map->map.getValue()).collect(Collectors.toList()));
Struck here , unable to loop / parse further .
how to get the collegeLoc value in this case ? any help would be great .
jsonObject.getAsString(key)?