我想解析下面的JSON代碼,並不能弄明白。我正在使用下面的代碼。但它不能找到對象。 getJsonObject查找名稱,那麼如何查找我的對象4106?找到JSONObject沒有找到對象
我的代碼:
JSONObject structure = Utilities.getJSONFromUrl(url);
JSONObject jobj = structure.getJSONObject("4106");
Log.w("JSON", jobj.toString())
我的JSON:
{
"id": 356,
"hassubcategories": true,
"subcategories": [
{
"id": 3808,
"CategoryName": "Current Products",
"CategoryImage": null,
"hassubcategories": true,
"subcategories": [
{
"id": 4106,
"CategoryName": "Architectural",
"CategoryImage": "2637",
"hassubcategories": true,
"subcategories": [
{
"id": 391,
"CategoryName": "Flooring",
"CategoryImage": "2745",
"hassubcategories": false
}
]
}
]
}
]
}
提示 - 這裏是你如何用JavaScript做到這一點:'structure.subcategories [0] .subcategories [0]' –