0

.

globalscope.json:

"object1": {
    "thing1": "",
    "thing2": "",
    "thing3": ""
},
"search": {
    "tracking": {
        "crawl": false,
        "index": true
    }
}

localscope.json

"object1": {
    "thing1": "some",
    "thing2": "new",
    "thing3": "data"
},
"search": {
    "tracking": {
        "crawl": true, /* !! It should update the booleans etc */
        "index": true
    },
    "somethingnew": 777 /* !! new values would be awesome but not essential */
}

.

I found what looks to be a solution using C#, but I need JS / Node please.

I'm looking for an agnostic tool, although defining a schema in the beginning would be ok too.

.

1 Answers1

0

You could combine two objects with the rest operator (...) which works similar to Object.assign

Example:

const obj1 = {
  a: 2,
  b: 3,
  h: 10
}

const obj2 = {
  b: 11,
  a: 12
}

const obj3 = {...obj1, ...obj2}

The result would be

{a: 12, b: 11, h: 10}
Alex Khristo
  • 477
  • 2
  • 8