Let's say I have two arrays of objects:
[
{
"key": "a",
"value": [1,2,3]
},
{
"key": "b",
"value": [1,2,3]
},
{
"key": "c",
"value": [1,2,3]
}
]
and
[
{
"key": "b",
"value": [8,9]
},
{
"key": "d",
"value": [1,2,3]
},
{
"key": "a",
"value": [4,5]
},
{
"key": "e",
"value": [3,4,5]
}
]
Is there any painless way to combine both arrays keeping all the keys and merging the values?
The result could be either
[
{
"key": "a",
"value": [1,2,3,4,5]
},
{
"key": "b",
"value": [1,2,3,8,9]
},
{
"key": "c",
"value": [1,2,3]
},
{
"key": "d",
"value": [1,2,3]
},
{
"key": "e",
"value": [3,4,5]
}
]
or
[
{
"a": [1,2,3,4,5]
},
{
"b": [1,2,3,8,9]
},
{
"c": [1,2,3]
},
{
"d": [1,2,3]
},
{
"e": [3,4,5]
}
]
Thank you!