我需要从对象树替换对象,我尝试了几种方法,但我不能替换对象树中的对象
let data = [
{
"accountId": 2
},
{
"accountId": 6,
"children": [{
"accountId": 8
}]
},
{
"accountId": 45
}
];
在上述对象数组我需要更换(当我知道accoundId
)
{
"accountId": 2
}
到
{
"accountId": 2,
"children": [
{
"accountId": 85
}
]
}
有什么办法(S)/库(S)做到这一点。
过得好了'children'?一些逻辑或硬编码数据? – nikhil
是的,它代表了子帐户(子帐户)api发送的那样的数据对象 – TIJ
不清楚。你怎么得到85的价值? – nikhil