[
{
"categoryId": "373",
"parentId": "3",
"categoryName": "张三",
"sunCategorys": [
{
"categoryId": "374",
"parentId": "373",
"categoryName": "张三一",
},
{
"categoryId": "375",
"parentId": "373",
"categoryName": "张三二",
}
]
},
{
"categoryId": "374",
"parentId": "3",
"categoryName": "李四",
"sunCategorys": [
{
"categoryId": "375",
"parentId": "374",
"categoryName": "李四一",
},
{
"categoryId": "376",
"parentId": "374",
"categoryName": "李四二",
}
]
}
]
我想把上面数据的categoryName 和 sunCategorys里面的categoryName,categoryId的id的值取出来,组合成这样的形式,请问应该如何去写
[
{
"text": "张三",
"children": [
{
"text": "张三一",
"id": 374
},
{
"text": "张三二",
"id": 375
}
]
},
{
"text": "李四",
"children": [
{
"text": "李四一",
"id": 375
},
{
"text": "李四二",
"id": 376
}
]
}
]