0

I have a multi-dimensional object like this one:

var map = {
    "a": {
        "aa": {
            "aaa":  "red",
            "aab":  "green"
        },
        "ab": "blue"
    }
    "b": {
        "ba": "orange"
    }
}

What I need is a function that would allow something such like:

var foo = getSubValue(map, "a.ab"); // "blue"

The second parameter of this sample has to be a string. I can't use the following:

var foo = map.a.ab

Any Idea of how to proceed, or of an existing implementation ? Thanks for your help.

Abrab
  • 751
  • 1
  • 8
  • 19
  • @deceze Before posting my question, I tried to find a similar one, but didn't succeed. I would appreciate if you would give the url of the one you are thinking about. EDIT: Never mind. I'm just a noob here, and didn't notice the link above my question. – Abrab Dec 15 '15 at 15:40
  • @dave Sorry Dave, when I say that I need to use a string, I mean that one string has to contain the whole path. – Abrab Dec 15 '15 at 15:45
  • Ah, well there's a link at the top of this question for that then – Dave Dec 15 '15 at 15:47

0 Answers0