How to access nested elements of json object using getJSONArray method
arrays, java, json
Solution
You have to decompose the full object to reach the `entry` array.
Assuming `REPONSE_JSON_OBJECT` is already a parsed `JSONObject`.
REPONSE_JSON_OBJECT.getJSONObject("result")
.getJSONObject("map")
.getJSONArray("entry");
Problem
I have a JSON response that looks like this: ``` { "result": { "map": { "entry": [ { "key": { "@xsi.type": "xs:string", "$": "ContentA" }, "value": "fsdf" }, { "key": { "@xsi.type": "xs:string", "$": "ContentB" }, "value": "dfdf" } ] } } } ``` I want to access the value of the `"entry"` array object. I am trying to access: ``` RESPONSE_JSON_OBJECT.getJSONArray("entry"); ``` I am getting `JSONException`. Can someone please help me get the JSON array from the above JSON response?