title: Obtain value from nested JSON dictionary via keypath without using eval
body: <p>I want to access a nested JSON dictionary via dynamically constructed keypath.<br>
  The keypath uses standard JSON dot and subscript operators.  (<code>.</code> and <code>[x]</code>)<br>
  E.g.:</p>
  
  <pre><code>var data = 
  {"title": "a_title",
   "testList": [
     {
       "testListItemKey": "listitem1"
     },
     {
       "testListItemKey": "listitem2",
            "deepTestList": [
              {
                "testListItemKey": "listitem1",
                        "testListItemDict":{
                           "subTitle": "sub_title",
                        }
              }]
     }]
  }
  </code></pre>
  
  <p>An example keypath string would be:</p>
  
  <pre><code>data.feedEntries[0].testList[2].deepTestList[1].testListItemDict.subTitle  
  </code></pre>
  
  <p>The simplest working solution I found so far is to use eval or function constructors:</p>
  
  <pre><code>function valueForKeypPath(data, keyPath) {
      "use strict";
      var evaluateKeypath = new Function('data', 'return data.' + keyPath);
      return evaluateKeypath(data);
  }
  </code></pre>
  
  <p>As I can't fully trust the JSON data I receive from a remote endpoint, I'd like to avoid eval et.al.</p>