0

Is there a way to do something like parse? but instead of parsing a stringified object, i'm supposed get the value based on an object path

let myObject = {
    property1: {
        property2: [
            {
                property3: "Hello World"
            }
        ]
    }
};

let path = "myObject.property1.property2[0].property3";
let value = JSON.parse(path);

expected value: "Hello World"

2
  • 1
    You're looking for eval(path). However, don't use eval(). Commented Oct 20, 2020 at 13:19
  • eval works, but unfortunately I'm not allowed to use it. Commented Oct 20, 2020 at 13:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.