我想解析下面的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]' –