The code you provided is not an object, no matter how you look at it.
{cards: [{id: 1}], [{id: 2}],[{id: 2}],[{id: 3}],[{id: 4}] ]
Let's break it down:
You open an object, but never close it. Fine, let's close it...
{cards: [{id: 1}], [{id: 2}],[{id: 2}],[{id: 3}],[{id: 4}] ]}
Now you (kind of) have an object and the first property (cards
) contains an array with a single object: [{id:1}]
, than you have a bunch of other properties without keys, which are on the same level with cards
, they are not inside the cards
property of your parent object, as I believe you intended...
... and you're also closing an array after your last keyless property, which I have no idea where you started (/ intended to start but forgot), so I had to remove that to in order to get a valid object.
My best guess at what your object was supposed to look like is:
{ cards: [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 } ] }
or, beautified...
Object = {
cards: [{
id: 1
},
{
id: 2
},
{
id: 3
},
{
id: 4
}]
}
You now have an array of objects in the cards
property of Object
. Another probable data structure would be
cards: [ [{ id: 1 }], [{ id: 2 }], [{ id: 3 }], [{ id: 4 }] ]
This is the structure @KindUser believed to be most probable for your data.
The conclusion:, it is quite clear your object is "man made". And it's erroneous. You either use a tool to validate and visualize your data (search for "JSON viewer", "beautify js", etc...) or you pay more attention to what you're doing.