0
let myJson={
"name1": {
    "name2": {
        "name3": {
            "value": 5
        }
    }
 }
}

And I have this string:

let string="name1.name2.name3";

How to access to myJson using this string? the result should be:

{ value:5 }

The right way is:

console.log(myJson.name1.name2.name3);

but I have a different scenario in which I must do so in the previous way (using the string).

halfer
  • 19,824
  • 17
  • 99
  • 186
yavg
  • 2,761
  • 7
  • 45
  • 115

0 Answers0