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错误。 –