我删除了很多不重要的东西来保持这个简单。我只想要url属性。
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"posts": [
{
"photos": [
{
"original_size": {
"url": "LINK",
"width": 612,
"height": 612
答案 0 :(得分:0)
String json = "...";
try {
JSONObject jsonObj = new JSONObject(json);
JSONObject respObj = jsonObj.getJSONObject("response");
JSONArray posts = respObj.getJSONArray("posts");
JSONObject firstPost = (JSONObject) posts.get(0);
JSONArray photos = firstPost.getJSONArray("photos");
JSONObject firstPhoto = (JSONObject) photos.get(0);
JSONObject photoSize = firstPhoto.getJSONObject("original_size");
String url = photoSize.getString("url");
Log.e("URL:", url );
} catch (JSONException e) {
e.printStackTrace();
}