classify and reorganize according to the value of a field
Source data:
var _arr = [{
aId: 1,
bId: 11,
cId: 112,
}, {
aId: 1,
bId: 11,
cId: 113,
}, {
aId: 1,
bId: 12,
cId: 114,
}, {
aId: 2,
bId: 21,
cId: 211,
}]
expectation:
[{
aId: 1,
children: [{
bId: 11,
children: [{
cId: 112
}, {
cId: 113
}]
}, {
bId: 12,
children: [{
cId: 114
}]
}]
}, {
aId: 2,
children: [{
bId: 21,
children: [{
cId: 211
}]
}]
}]