I need to merge multiple json objects by common IDs. My issue is that my objects have different keys for the ID.
var object1 = [
{ "name":"apples" ,"w": 1, "x": 2 },
{ "name":"banana" ,"w": 1, "x": 2 },
{ "name":"cherry" ,"w": 1, "x": 2 },
];
var object2 = [
{ "type":"banana" ,"y": 3, "x": 4 },
{ "type":"cherry" ,"y": 3, "x": 4 },
];
I would like to obtain :
var object1 = [
{ "name":"apples" ,"w": 1, "x": 2 },
{ "name":"banana" ,"w": 1, "x": 4, "y": 3 },
{ "name":"cherry" ,"w": 1, "x": 4, "y": 3 },
];
I want to use the same Array [object1] instead of creating a new one. I created a codepen here