我尝试合并类似的东西(我在 json 中显示)
[["Field1","0"],["Field2","0"],["Field3","0"]]
和
{"0":{"Name":"Foo","Lastname":"Bar"}}
当我做
$.extend({}, firstArray, secondArray);
我进入 JSON
{
"0":{"Name":"Foo","Lastname":"Bar"},
"1":["Field1","0"],
"2":["Field2","0"]
}
如您所见,第一个数组与第二个数组混合在一起。我希望它像这样被包裹起来
{
"0":{"Name":"Foo","Lastname":"Bar"},
"1":[ "1": ["Field1","0"],"2":["Field2","0"]]
}
因此,稍后当我使用它时,我可以将字段内容作为一个数组获取。有可能吗?我无法让它工作。有任何想法吗?