I have a JSON Object like this:
{
"Items": [{
"Name": "CATS",
"Value": 5.0
}, {
"Name": "DOGS",
"Value": 6.0
}, {
"Name": "FISH",
"Value": 9.0
}, {
"Name": "CATS",
"Value": 4.0
}, {
"Name": "DOGS",
"Value": 2.0
}, {
"Name": "FISH",
"Value": 3.0
}]
}
As you can see, there are 2 of each key and I would like to reduce them to 1 and add all the values. So what I want to achieve is this:
{
"Items": [{
"Name": "CATS",
"Value": 9.0
}, {
"Name": "DOGS",
"Value": 8.0
}, {
"Name": "FISH",
"Value": 12.0
}]
}
What is the most efficient way to implement this?
Thanks!