【发布时间】:2017-09-15 12:15:39
【问题描述】:
我有以下 JSON 结构:
{
"schedule":{
"day":[
{
"id":"Monday",
"items":[
{
},
{
}
]
},
{
"id":"Tuesday",
"items":[
{
},
{
}
]
}
]
}
}
我基本上想做的是到达 day 数组内的 items 数组,该数组位于 schedule 对象内。
但每当我尝试获取第二个 JSON 数组时,我都会得到 getJSONArray JSONArray 中的 (int) 不能应用于 (java.lang.String)。
JSONObject baseJsonResponse = new JSONObject(dayJSON);
JSONArray dayArray = baseJsonResponse.getJSONObject("schedule").getJSONArray("day").getJSONArray("items");
【问题讨论】:
-
提示:你必须使用 for 循环。
-
尝试将 Json getJsonArray 和 getJsonObject 的 getter 分开以分隔行,我相信您会发现问题所在。它基本上说您正在尝试将字符串提取到数组中
-
@Ibrahim for (int i = 0; i ...等等...riiight