title: Traversing JSON tree with variable value instead of literal not working using NodeJS
body: <p>I am trying to pull data from a online API in JSON format as abstractly as possible.</p>
  
  <p>I have code in the exact same structure as this:</p>
  
  <pre><code>require("request")
  
  var url = ""//Myurl
  
  request({
  url: url,
  json: true
  }, function (error, response, body) {
  
  if (!error &amp;&amp; response.statusCode === 200) {
      console.log(body) 
  }
  })
  </code></pre>
  
  <p>And I have a JSON like this:</p>
  
  <pre><code>    { John:
         { ID: 1212,
           Age: 12
         }
      }
  </code></pre>
  
  <p>I want to refer to "John" using this way</p>
  
  <pre><code>      var tempName = "John";//not limited to it being in the same scope
        console.log(body.tempName.ID);
  </code></pre>
  
  <p>instead of going this way</p>
  
  <pre><code>      console.log(body.John.ID);
  </code></pre>
  
  <p>to access his ID. </p>
  
  <p>I have tried using for each on the body response to get the name and then access it through that, but I couldn't get that right. </p>