0

嗨,我是 javascript 新手,需要将以下输入数组转换为 javascript 中提到的输出

需要一个 javascript 解决方案来获得所需的输出

input= [
    [
        "item10",
        "item4",
        "item3",
        "item2",
        "item1"
    ],
    [
        "item5",
        "item3",
        "item2",
        "item1"
    ],
    [
        "item9",
        "item8",
        "item7",
        "item6",
        "item1"
    ]

]
output= {"value":"3","name":"root","children": [ {"value":"3","name":"item 1","children": [ {"value":"2","name":"item 2","children": [ {"value":"2","name":"item 3","children": [ {"value":"1","name":"item 4","children": [ {"value":"1","name":"item 10","children": [ ]}]},{"value":"1","name":"item 5","children": [ ]}]}]},{"value":"1","name":"item 6","children": [ {"value":"1","name":"item 7","children": [ {"value":"1","name":"item 8","children": [ {"value":"1","name":"item 9","children": [ ]}]}]}]}]}]};
4

0 回答 0