title: Referencing a JSON key with Javascript variable
body: <p>How do I replace the "Argentina" key with a javascript variable string?</p>
  
  <pre><code>jQuery(document).ready(function() {
  
      $.getJSON('countries.json', function(data) {
  
          var output= data.Argentina[0].countryPhone1;
  
          alert(output);
  
       });
  });
  </code></pre>
  
  <p>Here's what my .json data file looks like:</p>
  
  <pre><code>{
      "Argentina": [{
          "countryName":"Argentina",
          "countryPhone1":"1234"
      }],
  
      "Brazil": [{
          "countryName":"Brazil",
          "countryPhone1":"5678"
      }]
  }
  </code></pre>
  
  <p>I tried applying the suggested solutions <a href="https://stackoverflow.com/questions/13833204/how-to-set-a-json-key-from-a-variable">here</a>, <a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=2&amp;ved=0CCQQFjAB&amp;url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F10055919%2Fjquery-json-how-to-define-key-from-variable&amp;ei=HjnqVP7LKc_9gwSo84KAAg&amp;usg=AFQjCNH6UkRnjeeGPeb7I4uybrGHx1hRBw&amp;sig2=EQeYO8eREUq0O_thZHIjIw&amp;bvm=bv.86475890,d.eXY" rel="nofollow noreferrer">here</a> and <a href="https://stackoverflow.com/questions/13474040/how-to-use-a-string-variable-as-key-in-a-json-object">here</a>, but I couldn't figure out a way to adapt them to my example.</p>