I have the following json file structure that includes years from 2008 to 2020, along with other keys such as location, name, etc.:
{"2008": 50, "2009": 60, "2010": 70, "2011": 80, etc...}
I am trying to group the years into another key and adding it to the original array:
{metric:
[{"year": 2008, "perc": 50},
{"year": 2009, "perc": 60},
{"year": 2010, "perc": 70},
{"year": 2011, "perc": 80}],
"2008": 50,
"2009": 60,
"2010": 70,
"2011": 80,
etc...
}
I think I need to create a range between 2008 to 2020, and if I detect a key that's within that range, I add to the metrics
group and add that to the array?