I need to populate a json file, now I have something like this:
{\"element\":{\"id\":10,\"quantity\":1}}
And I need to add another \"elemen
My proposition is to use different data structure that proposed already in other answers - it allows you to make push on card.elements and allow to expand card properties:
let card = {
elements: [
{"id":10,"quantity":1}
],
//other card fields like 'owner' or something...
}
card.elements.push({"id":22,"quantity":3})
console.log(card);