I want to display a specific value of different objects in a template. The path of the value to display depends of the object.
Here a example :
let obj = {
"a": "a",
"b": {
"1": "1",
"2": "READ ME"
}
}
let obj2 = {
"x": "x",
"y": {
"foo": "1",
"bar": {
"test": "READ ME"
}
}
}
In this example I want to read the value "READ ME" like this obj.b.2 or obj['b']['2'] for the first object.
However I don't know where is the READ ME value depending on objects.
To know where is located the value to display, I pass to my tempate a config array with the list of the keys to call: like this :
config = ['b', '2'] // For the first object
config = ['y', 'bar', 'test'] // For the second object
How can I display "READ ME" in my template with my list of keys ?