I'm not that pro at JSON I have some knowledge but I think not that deep knowledge and I want to create a custom JSON from an array of objects. I hope you can help me.
I'm using JavaScript and NodeJS....
So I have the next data coming from my backend (array of objects):
and I want to create a JSON like this:
{
"items":[
{
"name":"extintor de agua",
"itemData":[
{
"caracteristica":"item 1", "header": "Header 1", "id":12867
},
{
"caracteristica":"item 2", "header": "Header 1", "id":12870
}
]
},
{
"name":"Extintor CO2",
"itemData":[
{
"caracteristica":"item 1", "header": "Header 1", "id":12873
},...
]
}
]
}
As you can see I retrieve multiple rows for the same Entity field for example: multiple rows for "extintor the agua" and multiple rows for "extintor CO2" and so on with many more items. In the JSON you can see that I'm assigning the Entity field one time as "name" and inside that a "item Data" that contains all the values from the multiple "extintor de agua" values.
can I do that with JSON? if so how can I do it. If the problem needs more explanation I can give it I hope you can help me :)