there is a way for merge array items by first item
_.merge({a: 1, c: [{y: 8}, {z: 9}]}, {b: 0, c: [{x: 5}]})
Result:
{
"a": 1,
"c": [
{
"y": 8,
"x": 5
},
{
"z": 9
}
],
"b": 0
}
what i want:
{
"a": 1,
"c": [
{
"y": 8,
"x": 5
},
{
"z": 9,
"x": 5 // <-------------------------
}
],
"b": 0
}
I want merge a source object by another used like a model. In case of array the model define only the first item of the collection and the source object should reflect the first model item into all the collection items.
c: [{x:5},{x:5},...]... because as of right now the result makes sense. You would just need to make your array have the same length as the rest of c one would think. Another option would be to merge everything, less that object, and then carry out custom functionality.