var jsonArray = {
"data":{
"List": [{
"authorityId": 1,
"authorityName": "",
"grade": "1001",
"fatherId": "0"
},
{
"authorityId": 2,
"authorityName": "",
"grade": "1002",
"fatherId": "0"
},
{
"authorityId": 3,
"authorityName": "",
"grade": "1003",
"fatherId": "0"
},
{
"authorityId": 4,
"authorityName": "",
"grade": "1004",
"fatherId": "0"
},
{
"authorityId": 5,
"authorityName": "",
"grade": "1005",
"fatherId": "0"
},
{
"authorityId": 6,
"authorityName": "",
"grade": "2101",
"fatherId": "1001"
},
{
"authorityId": 7,
"authorityName": "",
"grade": "2102",
"fatherId": "1001"
},
{
"authorityId": 8,
"authorityName": "",
"grade": "2103",
"fatherId": "1001",
},
{
"authorityId": 9,
"authorityName": "",
"grade": "2201",
"fatherId": "1002"
},
{
"authorityId": 10,
"authorityName": "",
"grade": "2202",
"fatherId": "1002"
},
{
"authorityId": 11,
"authorityName": "",
"grade": "2301",
"fatherId": "1003"
},
{
"authorityId": 12,
"authorityName": "",
"grade": "2302",
"fatherId": "1003"
}
]
}
}
expect to spell the following tree data format (implemented in jq or es6)
correspondence: fatherid
data: of the parent"s grade= child [
{
label: " 1",
children: [{
label: " 1-1",
children: [{
label: " 1-1-1"
}]
}]
}, {
label: " 2",
children: [{
label: " 2-1",
children: [{
label: " 2-1-1"
}]
}, {
label: " 2-2",
children: [{
label: " 2-2-1"
}]
}]
}
]