0
考慮以下兩個數組。我如何將數組「行」追加到數組「array1」。我嘗試過.push,但它附加在數組之外。我也嘗試過。沒有給我想要的結果。將javascript數組插入另一個數組
array1 = [
{
"Activity #": "1111111",
"Customer": "Last, First",
"Tenure": "0 Year 2 Months",
"Account #": "0000000"
}];
lines = [
{
"Line #": "1",
"Action Required": "New",
"Status": "Closed",
"Product Line": "test line1",
"Product": "product1"
},
{
"Line #": "2",
"Action Required": "New",
"Status": "Closed",
"Product Line": "test line2",
"Product": "product2"
}];
我想要這樣的事情。
my_array = [
{
"Activity #": "1111111",
"Customer": "Last, First",
"Tenure": "0 Year 2 Months",
"Account #": "0000000",
"lines": [{
"Line #": "1",
"fields": "keys"
},
{
"Line #": "2",
"fields": "keys"
}]
}]
與上述使用的方法我得到了類似的東西。
my_array = [
{
"Activity #": "1111111",
"Customer": "Last, First",
"Tenure": "0 Year 2 Months",
"Account #": "0000000"
}, [
{
"Line #": "1",
"fields": "keys"
}, {
"Line #": "2",
"fields": "keys"
}]
];
希望有人能幫助,我的問題很清楚。
@Allan:據我所知,這與JSON無關。 –
是的,我確認,與json無關,編輯時發生shorcut錯誤。 –