我有一个 JSON 表示菜单项。
一个菜单项可以有一个子菜单项,而子菜单项又可以有另一个子菜单项,依此类推。
输入 JSON 通过父 ID 关联菜单项。我试图将其转换为一个模型,其中每个菜单项都有其子菜单项的一部分。
子菜单有三层深。我已经设法解析了两个级别,但我不知道为什么没有解析第三个级别。我一直在调试这个问题几个小时。我会很感激一些帮助。
menu2.sjon
[
{
"category_id": 4,
"category_id_400": "'SCHOO",
"name": "School Supplies",
"parent_id": 2,
"position": 2,
"level": 2,
"status": 1,
"url": "http://www.booksrus.kw/sa-en/school-supplies.html"
},
{
"category_id": 141,
"category_id_400": "'SCHBA",
"name": "School Bags",
"parent_id": 4,
"position": 12,
"level": 3,
"status": 1,
"url": "http://www.booksrus.kw/sa-en/school-supplies/school-bags.html"
},
{
"category_id": 269,
"category_id_400": "'AEP",
"name": "Bags Knapsack with Trolley",
"parent_id": 141,
"position": 1,
"level": 4,
"status": 1,
"url": "http://www.booksrus.kw/sa-en/school-supplies/school-bags/bags-knapsack-with-trolley.html"
}
]
输出
Rootitems:
[4 School Supplies
> 141 School Bags
//Third level should appear here
]
largeQ
相关分类