I'd like to add JSON object of a json file into another one. Here is an example :
{
"HOUSES": {
"1": {
"NAME": "House1",
"PEOPLE": {},
"ID": 1
},
"2": {
"NAME": "House2",
"PEOPLE": {},
"ID": 2
},
"3": {
"NAME": "House3",
"PEOPLE": {},
"ID": 3
}
}
}
And people object :
{
"1": {
"NAME": "People1"
},
"2": {
"NAME": "People2"
},
"3": {
"NAME": "People3"
}
}
Now I'd like to add the people object into House1.
I tried that :
var extend = require('util')._extend;
var obj1 = house.PEOPLE; //var content : {}
var obj2 = extend(people, obj1); //var people content people object
This code replace all house1 by the people object. How can I add people object in the sublevel PEOPLE of house1?
I tried with object-assign too, and I have the same problem.
Thanks !