I have the following JSON:
[
{Id: "1", Id2: "1", Year: "2019", Month: "1", Value: "123"},
{Id: "1", Id2: "1", Year: "2019", Month: "2", Value: "3"},
{Id: "1", Id2: "1", Year: "2019", Month: "3", Value: "-123"},
{Id: "1", Id2: "1", Year: "2019", Month: "4", Value: "-4123"},
...
{Id: "1", Id2: "1", Year: "2020", Month: "1", Value: "214"},
{Id: "1", Id2: "1", Year: "2020", Month: "2", Value: "-41123"},
{Id: "1", Id2: "1", Year: "2020", Month: "3", Value: "12344"},
{Id: "1", Id2: "1", Year: "2020", Month: "4", Value: "1232"}
]
Which I'd like to transform into this:
[{
Year : "2019",
data : [{
Month : "01",
Value : "123"
},{
Month : "02",
Value : "2223"
}...
},{
Year : "2020",
data: [{
Month : "01",
Value : "214"
}...
}]
Not sure how to do this easily, seems it's beyond me right now.
Is anyone able to point me in the right direction?
Many thanks,
Fish