I am trying to parse a nested JSON as shown below:
{
"a":{"aa":"11","bb":"232"},
"b":{"aa":"111","bb":"224"},
"c":{"aa":"121","bb":"232"}
}
I am trying to get to the nested JSON part using loops:
JSONParser parser = new JSONParser();
JSONObject infoJSON = (JSONObject) parser.parse(new FileReader(new File("resources/abc.json")));
for(int i=0 ;i< infoJSON.size(); i++){
JSONObject innerJSON = (JSONObject) infoJSON.get(i);
System.out.println(innerJSON.keySet());
}
It throws me NullPointerException
. I feel there is some issue with the iteration.