I'm new to Groovy and couldn't find any resources related to this. I'm trying to extract data from a "dates" object and put it in an array of fixed objects within it. The reason for it is that the objects within dates will change and I'd like to put into fixed for easy manipulation:
Original:
{
"dates": {
"2021-02-08": "8",
"2021-02-09": "8",
"2021-02-10": "8"
}}
Output wanted:
{
"dates": [
{
"date": "2021-02-08",
"value": "8"
},
{
"date": "2021-02-09",
"value": "8"
},
{
"date": "2021-02-10",
"value": "8"
},
]}
I'm trying to use the current codes:
arrayList = []
arrayList.add(content[0].dates)
It returns an [[2021-02-08:8, 2021-02-09:8, 2021-02-10:8]], but I cannot extract it as an array.
Any thoughts?