我有一個奇怪的json字符串,我從其他api接收,現在我試圖從json字符串中提取信息,看起來像這樣。閱讀android中的複雜json字符串
var json={"student":{
"0":[{
"name":"manet",
"marks":114
}],
"1":null,
"2":null,
"4":null,
"5":null,
"6":null,
"7":[{
"name":"Om",
"marks":75
}], "employye": {
"0":[{
"name":"nn",
"value":23
}],
"1":[{"name": "tt",
"value": 67}]
"2":null,
"3":null,
"4":null,
"5":null,
"6":null,
"7":[{
"name":"Om",
"value":75
}]
}};
我想讀此JSON這樣,但不知道我應該怎麼遍歷下學生的價值和employye
try {
JSONObject reader = new JSONObject(data);
Log.d(TAG, ""+reader.length());
JSONObject student = reader.getJSONObject("student");
Log.d(TAG, "Student Array"+student.getJSONArray("0")); // here is the issue
} catch (JSONException j) {
j.printStackTrace();
}
感謝
[如何解析這個嵌套的JSON數組在android]可能的重複(http://stackoverflow.com/questions/17673057/how-to-parse-this-nested-json-array-in-android) – ben75 2014-10-11 20:12:11