Skip to content

数组转树

输入符合规则的数据和参数,看看数组转树实现的效果

数据:
参数:
输出:
[
  {
    "id": "1",
    "pid": "",
    "children": [
      {
        "id": "2",
        "pid": "1",
        "children": [
          {
            "id": "4",
            "pid": "2",
            "children": []
          }
        ]
      },
      {
        "id": "3",
        "pid": "1",
        "children": []
      }
    ]
  }
]

Released under the MIT License.