树形JSON需求改造?求指导

新手上路,请多包涵

clipboard.png

目前有这么一个需求,数据格式如下,试了递归的方法感觉不太合适,不知道有没有 好的解决方案,还请大神们赐教:

[{
    "equTypeId": "e38d3895-a4e0-4d22-babe-6c77e0c61a6f",
    "professionIndustryId": "1",
    "typeName": "11",
    "typeCode": "112",
    "orders": 0,
    "children": [{
        "equTypeId": "62fe456d-5027-48df-9cb7-bb48dce3ccca",
        "professionIndustryId": "1",
        "typeName": "asd ",
        "typeCode": "123124",
        "orders": 0,
        "children": [{
            "equTypeId": "84b6c4e0-aa8a-41dd-9b05-b8d2d2f6d2a6",
            "professionIndustryId": "1",
            "typeName": "123234",
            "typeCode": "qweer",
            "orders": 0,
            "children": []
        }, {
            "equTypeId": "6c5c01fd-93d2-4983-afe1-8a268ffcb047",
            "professionIndustryId": "1",
            "typeName": "sfs",
            "typeCode": "23324",
            "orders": 1,
            "children": []
        }]
    }]
}, {
    "equTypeId": "c9ed8d48-a5ae-4649-96ef-161514198d03",
    "professionIndustryId": "1",
    "typeName": "ad",
    "typeCode": "21321",
    "orders": 1,
    "children": [{
        "equTypeId": "2d330fb3-38ec-4ac4-b6ed-f8183d5c0b0b",
        "professionIndustryId": "1",
        "typeName": "ads",
        "typeCode": "453",
        "orders": 0,
        "children": []
    }]
}]
阅读 1.3k
1 个回答

需要啥转换
选中类型 获取它下面的 chidlren , 递归渲染就可以了
可以优化的在查找上, 遍历成 map, 就不用每次递归查找了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题