I want to get a result of updating two json data, the second json updated existing data from first json and also it has new data as well, these are my structure:
var origin = {
"allTest": [
{
"testName": "A",
"platform": [{"name": "chrome", "area": ["1"]}]
},
{
"testName": "B",
"platform": [{"name": "Edge", "area": ["2"]}]
}
]
};
var updated = {
"allTest": [
{
"testName": "A",
"platform": [{"name": "chrome", "area": ["1"]}]
},
{
"testName": "B",
"platform": [{"name": "Safari", "area": ["3"]}]
},
{
"testName": "C",
"platform": [{"name": "IE", "area": ["4"]}]
}
]
}
var result = origin.allTest.concat(updated.allTest);
console.log(result);
result:
[ { testName: 'A', platform: [ [Object] ] },
{ testName: 'B', platform: [ [Object] ] },
{ testName: 'A', platform: [ [Object] ] },
{ testName: 'B', platform: [ [Object] ] },
{ testName: 'C', platform: [ [Object] ] } ]
but this is not the current update, i would like to update origin data like this:
expected result:
{
"allTest": [
{
"testName": "A",
"platform": [{"name": "chrome", "area": ["1"]}]
},
{
"testName": "B",
"platform": [{"name": "Edge", "area": ["2"]},{"name": "Safari", "area": ["3"]}]
},
{
"testName": "C",
"platform": [{"name": "IE", "area": ["4"]}]
}
]
}
can you please help me to solve it. i am new in codding, thanks