我目前正在使用以下代码:
function mergeFaculty(json){
tempList = $.extend(tempList, json);
console.log(JSON.stringify(tempList));
}
但是,它不起作用。
对象如下:
{"modulos":{"id":"1","name":" Usuarios","paginas":{"id":"1","name":" Listado Usuarios","facultades":{"id":"1","name":" ver"}}}}
{"modulos":{"id":"1","name":" Usuarios","paginas":{"id":"1","name":" Listado Usuarios","facultades":{"id":"2","name":" editar"}}}}
知道为什么它不起作用吗?
最佳答案
尝试将扩展函数更改为:$.extend(true, tempList, json);
,它应该允许深度合并
关于javascript - 如何合并两个嵌套的 javascript 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42684341/