我想从下面的json中检索第一个对象:
"categories": {
"Blues": {
"ID": 5,
"name": "Blues",
"year": "1980"
},
"Reggae": {
"ID": 62,
"name": "Reggae",
"year": "1992",
}
},
...
}
目前,我正在解析它:
JSONObject catsObject = jsonObject.getJSONObject("categories");
JSONArray names = catsObject.names();
JSONObject categObj = object.getJSONObject(names.get(0).toString());
String year = categObj.getString("year");
Log.d(TAG, "The year is " + year);
但是行JSONObject categObj = object.getJSONObject(names.get(0).toString());
正在返回此错误
10-19 22:14:42.554 29056-29056 / com.ozuf.musichistory W / System.err:org.json.JSONException:Blues没有价值