我有来自 WordPress 网站的 JSON 内容
"posts": [
{
"id": 67986,
"type": "post",
"title": "Launching New eBooks",
"thumbnail_images": {
"full": {
"url": "http://www.marineinsight.com/wp-content/uploads/2015/04/boiler-featured.png",
"width": 700,
"height": 500
},
"medium": {
"url": "http://www.marineinsight.com/wp-content/uploads/2015/04/boiler-featured-300x214.png",
"width": 300,
"height": 214
},
}
}
我想获取url
frommedium
以显示为图像。在参考了一些 SO 问题后,我制作了这段代码并尝试进入循环。但不知何故,我得到了整个thumbnail_images
JSONObject jsono = new JSONObject(data);
jarray = jsono.getJSONArray("posts");
for (int i = 0; i < jarray.length(); i++) {
JSONObject object = jarray.getJSONObject(i);
JSONArray bigImage = object.getJSONArray("thumbnail_images");
for (int j = 0; j < bigImage.length(); j++) {
JSONObject tiObj = bigImage.getJSONObject(j);
JSONArray tiMed = tiObj.getJSONArray("medium");
for (int k = 0; k < tiMed.length(); k++) {
JSONObject tiMedU = tiMed.getJSONObject(i);
String imageURL = tiMedU.getString("url");
}
}
actor = new Actors();
actor.setName(object.getString("title"));
actor.setDescription(object.getString("url"));
actor.setImage(imageURL);
actor.setDob(object.getString("content"));
actorsList.add(actor);
}
无法弄清楚上面的循环中有什么问题。任何帮助都会很棒。谢谢