有如下这种格式{ "2": { "id": 2, "name": "demo1", "lv1": { "4": { "id": 20, "name": "demo1-1", "lv2": { "2": { "id": 2, "name": "demo1-1-1" }, "3": { "id": 3, "name": "demo1-1-2" } } }, "7": { "id": 23, "name": "demo1-2" } } }, "3": { "id": 4, "name": "demo2", "lv1": { "6": { "id": 34, "name": "demo2-1", "lv2": { "3": { "id": 3, "name": "demo2-1-1" } } }, "8": { "id": 55, "name": "demo2-2" } } }}需要转换成这种格式[{ "value": "2", "text": "demo1", "children": [{ "value": "20", "text": "demo1-1", "children": [{ "value": "2", "text": "demo1-1-1" }, { "value": "3", "text": "demo1-1-2" } ] }] }, { "value": "4", "text": "demo2", "children": [{ "value": "34", "text": "demo2-1", "children": [{ "value": "3", "text": "demo2-1-1" }] }, { "value": "55", "text": "demo2-2" } ] }]要求新数据value跟原数据id是对应关系,新手调试了一整天都没效果,求大牛解答。
添加回答
举报
0/150
提交
取消