I have 2 json objects in node.js
x= { '20': { length: '2', payload: [ '11', '22' ] } };
y= { '23': { length: '2', payload: [ 'ef', 'ab' ] } };
I want to combine them such that they become;
z=
{
'20': { length: '2', payload: [ '11', '22' ] },
'23': { length: '2', payload: [ 'ef', 'ab' ] },
};
How can this be done in node.js?
EDIT: I found an easy answer myself. Cannot answer as question has been marked as duplicate.
Use underscore module.
var _under = require("underscore");
z= _under.extend(x, y);