mardi 9 octobre 2018

JSON pointers and fetching data

I am working on a nested js application that is attempting to create a clean json schema - from more raw data.

So as I loop through the data - I want to pick up the label value which is nested like this.

label: data[x]["title"]["values"]["en"]

I want to create in the parent a pointer - to this data so

parentLabelPointer : "title.values.en"


but I can not simply do a get of this variable (using ember) like this

label: data[x][this.get("parentLabelPointer")]

if it was just one level - this would work. e.b. "parentLabelPointer : "title""

is there a clean way to pick this data up -- without having to try and drill down to the data in nested arrays like ["title"]["values"]["en"]?

this is so I can make the module more modular -- if its to work with different data sets and different nesting levels.




Aucun commentaire:

Enregistrer un commentaire