如何解析这个json数组

时间:2018-01-08 12:58:14

标签: android json

如何获取日期数组中的键我可以解析直到'2'如何获得19:00:00

 "date_times": {
          "2": {
            "2018-01-08": [
              **"19:00:00"**
            ],
            "2018-01-09": [
              "13:30:00",
              "19:00:00"
            ],
            "2018-01-10": [
              "13:30:00",
              "19:00:00"
            ],
            "2018-01-11": [
              "13:30:00",
              "19:00:00"
            ]
          }
        }

1 个答案:

答案 0 :(得分:1)

如果您担心从jsonobject获取密钥。然后在Iterator上使用keys

 try {
        JSONObject resObject = new JSONObject(response);
        Iterator<String> iterator = resObject.keys();
        while (iterator.hasNext()) {
            String key = iterator.next();// this will be your date
            JSONArray data = resObject.getJSONArray(key);// And this is your data

        }
    } catch (Exception e) {
    }

这只是一个根据您的需要进行修改的示例