如何解析嵌套的jsonObject?

时间:2017-12-22 11:30:34

标签: android json

如何在android中解析这个jsonObject并将列表传递给recyclerview适配器?

{  
   "10:00-18:00":[  
      1,
      2,
      3,
      4,
      5,
      6,
      0
   ],
   "18:00-23:00":[  
      1,
      2,
      3,
      4,
      5,
      6,
      0
   ]
}

1 个答案:

答案 0 :(得分:-2)

只需在外部密钥Iterator上使用JSonObject

try {
        JSONObject resObject = new JSONObject(jsonString);
        Iterator<String> iterator = resObject.keys();
        while (iterator.hasNext()) {
            String key = iterator.next();
            JSONArray jsonArray = resObject.getJSONArray(key);
            // Parse array here

        }
    }catch (Exception e){
        e.printStackTrace();
    }
相关问题