vendredi 8 juillet 2016

Combine or merge JSON on node.js without jQuery

I have multiple JSON like those

var object1 = {name: "John"};
var object2 = {location: "San Jose"};

They are not nesting or anything like that. Just basically different fields. I need to combine them into one single JSON in node.js like this:

{name: "John", location: "San Jose"}

I can use jQuery just fine. Here is a working example in the browser:

http://jsfiddle.net/qhoc/agp54/

But if I do this in node.js, I don't want to load jQuery (which is a bit over use, plus node.js' jQuery doesn't work on my Windows machine).

So is there a simple way to do things similar to $.extend() without jQuery?

Aucun commentaire:

Enregistrer un commentaire