把以下数据处理成这样的
// 源数据
var arr = [{
name: "河南",
url: "*",
child: [{
name: "濮阳",
url: "*",
child: [{
name: "南乐县",
url: "nale.html"
},
{
name: "清丰县",
url: "qingfeng"
}
]
},
{
name: "鹤壁",
url: "hebi.html"
},
]
},
{
name: "广东",
url: "*",
child: [{
name: "深圳",
url: "*",
child: [{
name: "宝安区",
url: "baoan"
},
{
name: "南山区",
url: "nanshan.html"
}
]
},
{
name: "广州",
url: "guangzhou"
},
{
name: "佛山",
url: "foshna.html"
}
]
},
]
要处理成这样的
var arr = [{
name: "河南",
url: "*",
child: [{
name: "濮阳",
url: "*",
child: [{
name: "南乐县",
url: "nale.html"
},
]
},
{
name: "鹤壁",
url: "hebi.html"
},
]
},
{
name: "广东",
url: "*",
child: [{
name: "深圳",
url: "*",
child: [
{
name: "南山区",
url: "nanshan.html"
}
]
},
{
name: "佛山",
url: "foshna.html"
}
]
},
]