I have 2 javascript array objects of the following format:
var input1 =
{
"a" : [
{
"id" : 1,
"name" : "gh"
}],
"b" : [
{
"id" : 2,
"name" : "ab"
}]
}
var input2 =
{
"a" : [
{
"id" : 3,
"name" : "cd"
}],
"b" : [
{
"id" : 4,
"name" : "gh"
}]
}
I am looking to format it in the following way :
var finaloutput =
{
"a" : [
{
"id" : 1,
"name" : "gh"
},
{
"id" : 3,
"name" : "cd"
}
],
"b" : [
{
"id" : 2,
"name" : "ab"
},
{
"id" : 4,
"name" : "gh"
}
]
}
I am trying to group the array without using any external libraries. Not very much familiar with linq in javascript , any built in functions available or any references?
Edit: I made the changes in the inputs since this is what I am expecting as inputs
"a","b"properties are going to be overwritten by the second set. So its just going to be{ a:[{id:3}], b:[{id:4}] }