var arr=[{
name:"总队",
id:"1",
alias:"zongdui",
children:[{
name:"第一支队",
id:"2",
parent_id:"1",
children:[
{
name:"第一大队",
id:"4",
parent_id:"2"
}
]},
{
name:"第二支队",
id:"3",
parent_id:"1",
children:[
{
name:"第二大队",
id:"5",
parent_id:"2"
}
]
}]
}]
How to recursively get name and id from this json? Request the code
Using recursion to implement
Link
I answered an almost identical question. . .
/q/10...
Why can’t I do this
You can use the json_decode function to convert the json string into an array operation