I am having a problem in accessing the JSONArray ("pages") while reading a json file in Java using the json-simple-1.1.1.jar
My json file is around 32MB of size and the format is as below:
{
"id": "0912898213",
"pages": [
{
"pageUrl": "http://www.example0.com",
"results": [
{
"number": "1"
},
{
"number": "2"
}
]
},
{
"pageUrl": "http://www.example1.com",
"results": [
{
"number": "3"
},
{
"number": "4"
}
]
}
]
}
Whereas, the Java code to access this json file is as below:
JSONParser parser=new JSONParser();
JSONObject pagesObject = (JSONObject) parser.parse(new FileReader(PATH_JSON_DataExtractor));
JSONArray jsonArray= (JSONArray) pagesObject.get("pages");
for(int i=0; i<jsonArray.size(); i++){}
PROBLEM: The jsonArray is null all the time. Although, the json format is correct and it should work as expected! The above Java code works with the given sample json (also above) but the Java code doesn't work with the 32MB json file. The location of the json file is also correct and the format is also correct, but still I am getting this access issue!
Where I am going wrong to access the json file? I have been looking around on similar questions, and I have followed the exact instructions to access the json file. But I am just lost in getting it right, therefore, looking for suggestions to make this code work. Thank you very much for your time!