I have a JSON object that has a few nested levels in it.
I am given a string that refers to the location of a specific object.
For instance, if my JSON object looked like:
countries: [
canada: {
capital: "ottawa",
territories: [
yukon: {
capital: "yellowknife",
...
}
...
]
...
}
and I'm given the string
"countries.canada.territories.yukon"
I want to get the object for Yukon.
How can I do this?