Here is an array of objects that I need to manipulate:
[
{
"name": "product1",
"Jan": 3,
"Feb": 2,
"Mar": 0,
"Apr": 1,
"May": 3,
"Jun": 0,
"Jul": 0,
"Aug": 0,
"Sep": 5,
"Oct": 0,
"Nov": 0,
"Dec": 0
},
{
"name": "product2",
"Jan": 4,
"Feb": 0,
"Mar": 0,
"Apr": 1,
"May": 1,
"Jun": 0,
"Jul": 0,
"Aug": 0,
"Sep": 5,
"Oct": 0,
"Nov": 0,
"Dec": 0
}
]
I want to create a new array with just the data values in the correct month order for each product like this:
[
{
"name": "product1",
"data": [3, 2, 0, 1, 3, 0, 0, 0, 5, 0, 0, 0],
},
{
"name": "product2",
"data": [4, 0, 0, 1, 1, 0, 0, 0, 5, 0, 0, 0],
}
]
Any suggestions on how to achieve this?