title: Printing JSON Dictionary in JavaScript
body: <p>I am getting the data from an API using JavaScript. </p>
  
  <p>The statement <code>console.log(json[0])</code> gives the result: </p>
  
  <pre><code>{"id":"1","username":"ghost","points":"5","kills":"18","xp":"10","diamonds":"0","level":"1","missionscomplete":"1"} 
  </code></pre>
  
  <p>Now I am trying to print the individual elements of this dictionary. How do I do this ? My code is below: </p>
  
  <pre><code>function loadLeaderboard(){
      $.get("http://localhost:8888/l4/public/api/v1/getLeaderboard",function(data){
          var json = $.parseJSON(data);
          console.log(json[0]);
          $.each(json[i], function(key, data) {
              console.log(key + ' -&gt; ' + data);
          });
      });
  }
  </code></pre>
  
  <p><strong>EDIT</strong>:
  The value of data as returned by the API is </p>
  
  <pre><code>["{\"id\":\"1\",\"username\":\"ghost\",\"points\":\"5\",\"kills\":\"18\",\"xp\":\"10\",\"diamonds\":\"0\",\"level\":\"1\",\"missionscomplete\":\"1\"}","{\"id\":\"2\",\"username\":\"seconduser\",\"points\":\"0\",\"kills\":\"3\",\"xp\":\"0\",\"diamonds\":\"0\",\"level\":\"0\",\"missionscomplete\":\"0\"}","{\"id\":\"3\",\"username\":\"goat\",\"points\":\"12\",\"kills\":\"13\",\"xp\":\"14\",\"diamonds\":\"10\",\"level\":\"10\",\"missionscomplete\":\"4\"}"] 
  </code></pre>
  
  <p>The value in json after the operation <code>var json = $.parseJSON(data);</code> is </p>
  
  <pre><code>["{"id":"1","username":"ghost","points":"5","kills":…diamonds":"0","level":"1","missionscomplete":"1"}", "{"id":"2","username":"seconduser","points":"0","ki…diamonds":"0","level":"0","missionscomplete":"0"}", "{"id":"3","username":"goat","points":"12","kills":…amonds":"10","level":"10","missionscomplete":"4"}"]
  </code></pre>