[
{name:"abc",path:"01"},
{name:"def",path:"02"},
{name:"aaa",path:"0101"},
{name:"bbb",path:"0102"},
{name:"ccc",path:"010101"},
....
]
用什么方法可以把上面一组多个并列的json按照path 2位树一组(01是0101的父级),转换成如下的树形结构呢,请高手帮忙。
[
{name:"abc",path:"01",son:[
{name:"aaa",path:"0101",son:[
{name:"ccc",path:"010101"},
]},
{name:"bbb",path:"0102"},
]},
{name:"def",path:"02"},
....
]