I have an object with key values, and those keys each contain an array of objects:
var obj = {
"0": [
{
"category": "A",
"index": 0,
"property": "Name",
"value": "Bob"
},
{
"category": "A",
"index": 0,
"property": "Surname",
"value": "Dylan"
}
],
"1": [
{
"category": "A",
"index": 1,
"property": "Name",
"value": "Elvis"
},
{
"category": "A",
"index": 1,
"property": "Surname",
"value": "Presley"
}
]
}
How would I go about merging the objects into one single array with the objects combined therein? The objective is to have the result return the following:
var obj2 = [
{
"category": "A",
"index": 0,
"property": "Name",
"value": "Bob"
},
{
"category": "A",
"index": 0,
"property": "Surname",
"value": "Dylan"
},
{
"category": "A",
"index": 1,
"property": "Name",
"value": "Elvis"
},
{
"category": "A",
"index": 1,
"property": "Surname",
"value": "Presley"
}
]
I've tried to make use of LoDash union and join, however to no avail.
question from:
https://stackoverflow.com/questions/65909800/merge-combine-object-arrays-into-single-object 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…