这是我需要验证的 JSON 文档。我必须检查孩子中的所有 parent_id 是否正确。如果所有父子 ID 都是正确的,我将返回一个“有效”字符串。
{
"id": 10,
"children": [
{
"id": 25,
"parent_id": 10,
"children": [
{
"id": 131,
"parent_id": 25,
"children": null
},
{
"id": 33,
"parent_id": 25,
"children": [
{
"id": 138,
"parent_id": 33,
"children": null
},
{
"id": 139,
"parent_id": 33,
"children": null
},
{
"id": 140,
"parent_id": 33,
"children": null
},
{
"id": 160,
"parent_id": 33,
"children": null
},
{
"id": 34,
"parent_id": 33,
"children": [
{
"id": 26,
"parent_id": 34,
"children": null
},
{
"id": 64,
"parent_id": 34,
"children": null
},
{
"id": 65,
"parent_id": 34,
"children": null
}
]
},
{
"id": 35,
"parent_id": 33,
"children": null
},
{
"id": 36,
"parent_id": 33,
"children": null
},
{
"id": 38,
"parent_id": 33,
"children": null
},
{
"id": 39,
"parent_id": 33,
"children": null
},
{
"id": 40,
"parent_id": 33,
"children": null
},
我从 API 中获取值,但现在我很难编码 Json 值
森林海
相关分类