如果嵌套多达10个级别,且每个级别具有不同的长度,则存在父级、子级、孙辈和更多类似于下面给出的json的关系(id
在每个列表中是唯一的)。找到uni_code
将另一个对象(子对象)插入其列表的最佳方法是什么
{
"id": "1",
"status": "active",
"created": "",
"children": [{
"id": "1",
"status": "active",
"created": "",
"children": [{
"id": "1",
"status": "active",
"created": "",
"children": [{
"id": "1",
"status": "active",
"created": "",
"children": [
],
"uni_code": "EGCFJ1"
},
{
"id": "1",
"status": "active",
"created": "",
"children": [
],
"uni_code": "D356RY"
},
],
"uni_code": "EGCFJ1"
},
],
"uni_code": "Y7TUP8"
},
{
"id": "4",
"status": "active",
"created": "",
"children": [
],
"uni_code": "WA1JNS"
},
],
"uni_code": "I429TD"
}
根据您在评论中提出的后续问题,我相信我现在理解了您的问题……并相应地更新了我的答案
通常,您可以通过使用递归调用自身的函数来遍历递归数据结构(如树)
我的意思是:
相关问题 更多 >
编程相关推荐