I have an output from my return array like the below:
[{
SENIORS: "SINGLE_MAN",
age: "U21",
fullName: "John Doe",
personId: "0001337"
}]
And I need to return this into a new format where I would need to add values from the above into new keys, some nested exactly like the below structure.
[
{
"personId": "0001337",
"Groups": [
{
"group":"SENIORS",
"status" :"SINGLE_MAN"
}
]
}
]
As you can see I have created a new key called Groups, and 2 new keys within this called group and status. Not sure hows best to create the keys and at the same time assign the old values to them. The original key of senior now needs to be a property of group.
I am using lodash if that can be used?