I have a array of two objects.
I would like to transforming two objects into a single object generically by a key - allocation. You can see that allocation fields is now grouping them all. (it becomes a array)
From allocation: {} to allocation:[]
May I ask how to achieve that?
Original array
[
{
"allocation": {
"name": "custom",
"customAllocations": [
{
"name": "Developed",
"weight": 0.75
},
{
"name": "Diversified",
"weight": 0.1
},
{
"name": "Global",
"weight": 0.15
}
]
}
},
{
"allocation": {
"name": "custom",
"customAllocations": [
{
"name": "Developed",
"weight": 0.35
},
{
"name": "Conservative",
"weight": 0.1
},
{
"name": "Global",
"weight": 0.55
}
]
}
}
]
Expected array
[
{
"allocation": [
{
"name": "custom",
"customAllocations": [
{
"name": "Developed",
"weight": 0.75
},
{
"name": "Diversified",
"weight": 0.1
},
{
"name": "Global",
"weight": 0.15
}
]
},
{
"name": "custom",
"customAllocations": [
{
"name": "Developed",
"weight": 0.35
},
{
"name": "Conservative",
"weight": 0.1
},
{
"name": "Global",
"weight": 0.55
}
]
}
]
}
]