I have the following JSON coming from a server in the variable of StringBuffer called response which I can see in the output after making it toString().
[{"_id": "Grocery", "Categories": [{"Pulses and Grains": ["Dals"]}, {"Beverages": ["Juices", "Tea", "Coffee", "Soft Drinks"]}]}, {"_id": "Stationary", "Categories": [{"Chart Paper": ["A4 Size Chart Paper", "A3 Size Chart Paper"]}]}]
The code I have written till now which is not solving my purpose:
JSONArray ar=new JSONArray(response.
JSONObject jObject = ar.getJSONObject(0);
JSONObject jObject = ar.getJSONObject(1);
String JObjectString=jObject.toString();
System.out.println("The JObject String "+JObjectString);
I need to store each and every element which includes "Pulses and Grains", "Dals", "Tea", "A3 size paper" etc. and every element in that array in a String variable. How can I access each and every element from the hierarchy since it is too nested.?