Say I have a config file in which I have paths to JSON properties. My JSON looks like:
var test = { test: { test2: { test3: 1 } } }
and I have a string str = "test.test2.test3"
I know I can access the top level one like this: var foo = "test", test[foo]
But test["test.test2.test3"] does not work. On the other hand test["test"]["test2"]["test3"] works, but this is not a one liner if I have more complex objects (some can be 5 levels in, some can be 3 etc)
Is there any way to access this property directly instead of splitting on the dot and looping through?