为了账号安全,请及时绑定邮箱和手机立即绑定

获取所有子元素并将其推入数组

获取所有子元素并将其推入数组

茅侃侃 2021-05-13 14:15:22
我有一个非常复杂的JSON数据,其中包含许多子节点/子节点。我正在竭尽全力使其扁平化,因此我实现了自己的目标。我只需要带走所有嵌套的“子级”和子级子级,然后将它们推入单个数组中即可。请帮帮我,下面是我的示例数据,{  "path": "/root",  "name": "Through_5cd5553eb7f004432205cb6b",  "type": "folder",  "children": [    {      "path": "/root/Through_5cd5553eb7f004432205cb6b/assets",      "name": "assets",      "type": "folder",      "children": [        {          "path": "/root/Through_5cd5553eb7f004432205cb6b/assets/proxies.png",          "name": "proxies.png",          "type": "file"        },        {          "path": "/root/Through_5cd5553eb7f004432205cb6b/assets/targets.png",          "name": "targets.png",          "type": "file"        }      ]    },    {      "path": "/root/Through_5cd5553eb7f004432205cb6b/codgen-for-wsil-backend-esg",      "name": "codgen-for-wsil-backend-esg",      "type": "folder",      "children": [        {          "path": "/root/Through_5cd5553eb7f004432205cb6b/codgen-for-wsil-backend-esg/assets",          "name": "assets",          "type": "folder",          "children": [          ]        },        {          "path": "/root/Through_5cd5553eb7f004432205cb6b/codgen-for-wsil-backend-esg/index.md",          "name": "index.md",          "type": "file"        }      ]    },    {      "path": "/root/Through_5cd5553eb7f004432205cb6b/index.md",      "name": "index.md",      "type": "file"    },    {      "path": "/root/Through_5cd5553eb7f004432205cb6b/jwt-implementation-esg",      "name": "jwt-implementation-esg",      "type": "folder",      "children": [        {          "path": "/root/Through_5cd5553eb7f004432205cb6b/jwt-implementation-esg/assets",          "name": "assets",          "type": "folder",          "children": [          ]        },        {          "path": "/root/Through_5cd5553eb7f004432205cb6b/jwt-implementation-esg/index.md",          "name": "index.md",          "type": "file"        }      ]    }  ]}
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 139 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信