lundi 9 avril 2018

Reflection in typescript

I have 2 objects

object 1:

{ 
 "navigation": {
  "top": [
   {
     "title": "",
     "url": "",
   },
   {
     "title": "netflix",
     "url": "netflixlink",

   },
   {
     "title": "viaplay",
     "url": "viaplaylink", 
  },
  ]
 }
}

object 2:

{ 
 "navigation": {
  "top": [
   {
     "title": "news",
     "url": "newslink",
   },
   {
     "title": "netflix",
     "url": "netflixlink",

   },
   {
     "title": "viaplay",
     "url": "viaplaylink", 
  },
  ]
 }
}

Object 1 contains some properties (not all). Object 2 contains all properties.

If object 1 does not contain a property i want to use the default property from object 2.

example: if title and url is not set, i want to use the default value from object 2. But if it is set, i want to keep the current value.

example 2: if top is not set, i want to use the default top.

does anybody have a clue as of how to do this? I heard something along the lines of Object.key(..) but i do not entirely understand this.

thankyou very much in advance :)





Aucun commentaire:

Enregistrer un commentaire