Here's the data structure:
myData = {scope:{results:{data:{one:{url:"The url"}}}}}
Define a base. Your string access path is relative to this:
var base = myData.scope.results;
And a function to access by a path:
function getIn(base, path) {
var components = path.split(".");
var current = base;
for (var i = 0; i < components.length; i++) {
current = current[components[i]];
}
return current;
}
And to use it:
getIn(base, "data.one.url")
>>> "The url"
Or relative to the root:
getIn(myData, "scope.results.data.one.url")
>>> "The url"
Of course more error handling is needed to make it robust to paths you don't expect.