0
{
"Items": [{
"__type": "Section1:#com.test.example",
"Info": {
}, {
"__type": "Section2:#com.test.example2",
"Allergy": [{
}]
}
}]
}
我怎么能分析上面的JSON对象,让我得到信息的项目和过敏的物品....解析JSON使用Java
JSONObject documentRoot = new JSONObject(result);
JSONArray documentChild = documentRoot.getJSONArray("Items");
JSONObject child = null;
for (int i = 0; i < documentChild.length(); i++) {
child = documentChild.getJSONObject(i);
}
上面粘贴的内容无效JSON。你能直接从有效的JSON源复制/粘贴吗? – mjuarez
请查看[Gson](https://code.google.com/p/google-gson/)这类内容。就像'Gson.fromJson()'一样简单,让对象脱离JSON字符串。无论如何,JSON确实看起来不正常。 – gausss