0

Below is my json response

{
    "name": "Vikram",
    "test:content" :{
    "test:title" : "school",
    "main" : {
        "test:label" : "value",
        "container": {
        "test:class" : "10th",
        "Details" : {
             "parentdetails" : ["some value"],
         }
     }
     }
    }
 }`
 

I am able to retrieve data for name with below format but how to get data of "parentdetails". Is there a way to retrieve data using JsonObject from Gson?If so, how to do it?

Object obj = jsonParser.parse(reader);
JSONObject stu = (JSONObject) obj;
String text = (String) stu.get("name");
OneCricketeer
  • 151,199
  • 17
  • 111
  • 216
Janani
  • 1
  • 1
  • 1
    `((JSONObject) obj).getJsonObject("main").getJsonObject("Details").getJsonArray("parentdetails")`. And then loop over it, or use `.getString(index)`. – Ivar Jun 26 '21 at 21:47

0 Answers0