如何将Jsons列表转换为一个层次嵌套JSON?

因此,假设我有一个像这样的Json列表:

[{"id":1,
  "name":"William",
  "children":[{"id":2,"name":"May"},{"id":3,"name":"Henry"}]},
 {"id":3,
  "name":"Henry",
  "children":[{"id":4,"name":"Matt"}]},
  {"id": 2,
   "name": "May",
   "children": []},
  {"id": 4,
   "name", "Matt",
   "children": []}]

如何将其转换为:

{"id":1,
      "name":"William",
      "children":[{"id":5,"name":"May", "children": []},
                  {"id":2,"name":"Henry", "children":["id": 4,
                                                      "name": "Matt",
                                                      "children":[]]} 
    }

谢谢!

评论