I have an array of objects with nested object, as shown below:
[
{
"metric1": 4.1,
"addons": {
"call_uuid_1": "13d1e097-0363-4a81-b9e4-85c6a770cdb2",
"ThisDN_1": "50002",
"call_uuid": "13d1e097-0363-4a81-b9e4-85c6a770cdb4",
"ThisDN": "50004"
}
},
{
"metric2": -12345.123412341234,
"addons": {
"call_uuid_2": "13d1e097-0363-4a81-b9e4-85c6a770cdb3",
"ThisDN_2": "50003",
"call_uuid": "13d1e097-0363-4a81-b9e4-85c6a770cdb4",
"ThisDN": "50004"
}
},
{
"metric3": -2345.123412341234,
"addons": {
"call_uuid_1": "13d1e097-0363-4a81-b9e4-85c6a770cdb2",
"ThisDN_1": "50002",
"call_uuid": "13d1e097-0363-4a81-b9e4-85c6a770cdb4",
"ThisDN": "50004"
}
},
{
"metric4": -345.12341234123414,
"addons": {
"call_uuid_2": "13d1e097-0363-4a81-b9e4-85c6a770cdb3",
"ThisDN_2": "50003",
"call_uuid": "13d1e097-0363-4a81-b9e4-85c6a770cdb4",
"ThisDN": "50004"
}
}
]
I want to merge some of the array objects with the same nested object addons
, so that the previous array becomes:
[
{
"metric1": 4.1,
"metric3": -2345.123412341234,
"addons": {
"call_uuid_1
": "13d1e097-0363-4a81-b9e4-85c6a770cdb2",
"ThisDN_1": "50002",
"call_uuid": "13d1e097-0363-4a81-b9e4-85c6a770cdb4",
"ThisDN": "50004"
}
},
{
"metric2": -12345.123412341234,
"metric4": -345.12341234123414,
"addons": {
"call_uuid_2": "13d1e097-0363-4a81-b9e4-85c6a770cdb3",
"ThisDN_2": "50003",
"call_uuid": "13d1e097-0363-4a81-b9e4-85c6a770cdb4",
"ThisDN": "50004"
}
}
]
Are there any ways to do this?