I have this this JSON.
{
"animals": [{
"name": "Cumi-Cumi",
"data": 1000
}, {
"name": "Udang",
"data": 300
}, {
"name": "Baranang",
"data": 12000
}, {
"name": "Cumi-Cumi",
"data": 1500
}, {
"name": "Udang",
"data": 500
}, {
"name": "Baranang",
"data": 17000
}, {
"name": "Cumi-Cumi",
"data": 2500
}]
}
How can I group the data key by its name, to be like this:
{
"animals": [{
"name": "Cumi-Cumi",
"data": [
1000, 1500, 2500
]
},
{
"name": "udang",
"data": [
300, 500
]
},
{
"name": "Baranang",
"data": [
12000, 17000
]
}
]
}