我正在尝试解析以下 JSON 代码,但无法弄清楚。我正在使用下面的代码。但它找不到对象。getJsonObject 查找名称,那么如何找到我的对象 4106?
我的代码:
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
}
]
}
]
}
]
}