traverse jsonobjects

0

Nice to greet you

I have this Json

{
  "returnState":1,
  "returnData":{
  "16777216":{
    "level":"1",
    "cate_shop_id":"16777216",
    "cate_name":"\u5e97\u94fa\u4ea7\u54c1"
  },
  "33554432":{
    "level":"1",
    "cate_shop_id":"33554432",
    "cate_name":"\u5316\u5986\u54c1”
  },
  "50331648":{
    "level":"1",
    "cate_shop_id":"50331648",
    "cate_name":"\u65e5\u7528\u767e\u8d27”,
    "child":{
      "50593792":{
        "level":"2",
        "cate_shop_id":"50593792",
        "cate_name":"\u6d17\u6f31\u7528\u54c1”,
        "child":{
          "50597888":{
            "level":"3",
            "cate_shop_id":"50597888",
            "cate_name":"\u7259\u818f
          },
          "50601984":{
            "level":"3",
            "cate_shop_id":"50601984",
            "cate_name":"\u6bdb\u5dfe”
          }
        }
      }
    }
  }
}
}

As I go through it to show that information. as you can see there are several jsonobject one inside another

With this code I see the parents:

JSONObject mainObject = new JSONObject(returnData);
       Iterator<String> keys = mainObject.keys();
       while (keys.hasNext()) {
                                String key = keys.next();
                                Log.i("Parser", "objeto : " + key);
                                JSONObject jsonObject1 = 
                                mainObject.getJSONObject(key);
                                valorName = jsonObject1.getString("level");
                                valorRate = jsonObject1.getString("cate_name");

How do I see the children and grandchildren of the third father?

Greetings

    
asked by Linette 21.06.2018 в 20:16
source

0 answers