1

I'm trying to mix this objects which contain an array:

var a = {[
    {...},
    {...},
    {...}
]};

var b = {[
    {...},
    {...},
    {...}
]};

in one level array:

[
    {...},
    {...},
    {...},
    {...},
    {...},
    {...}
];

In JavaScript, I'm trying this without success:

var arr = a.concat(b);

because this gives me:

[
    {[
      {...},
      {...},
      {...}
    ]},
    {[
      {...},
      {...},
      {...}
    ]}
]

how can I obtain one level array?

vitto
  • 18,266
  • 30
  • 88
  • 128

1 Answers1

4

That's because a and b are not arrays. Assuming you can modify the json format (and you should as it's not valid) you could change it for this

var a = [
    {...},
    {...},
    {...}
];

var b = [
    {...},
    {...},
    {...}
];

Then your code would work just fine

Claudio Redi
  • 65,896
  • 14
  • 126
  • 152