I am trying to showcase a specific value from different objects within a template. The path of the desired value depends on the object being referenced.
For example:
let obj = {
"a": "a",
"b": {
"1": "1",
"2": "READ ME"
}
}
let obj2 = {
"x": "x",
"y": {
"foo": "1",
"bar": {
"test": "READ ME"
}
}
}
In this scenario, I aim to access the value "READ ME" using expressions like obj.b.2
or obj['b']['2']
for the first object. However, since I don't always know the location of the "READ ME" value in different objects.
To pinpoint the location of the value to display, I provide my template with a configuration array containing the keys needed to access it. For instance:
config = ['b', '2'] // For the first object
config = ['y', 'bar', 'test'] // For the second object
How can I effectively display "READ ME" in my template using the specified list of keys?