title: Convert array of hashes to json
body: <p>I want to convert an array of hashes that I create like this:</p>
  
  <pre><code>while(...)
  {
      ...
      push(@ranks, {id =&gt; $id, time =&gt; $time});
  }
  </code></pre>
  
  <p>To JSON:</p>
  
  <pre><code>use JSON;
  $j = new JSON;
  print $j-&gt;encode_json({ranks =&gt; @ranks});
  </code></pre>
  
  <p>But it is outputting this:</p>
  
  <pre><code>{"ranks":{"time":"3","id":"tiago"},
   "HASH(0x905bf70)":{"time":"10","id":"bla"}}
  </code></pre>
  
  <p>As you can see it isnt able to write on of the hashes and there's no array...</p>
  
  <p>I would like to output a JSON string that looked like this:</p>
  
  <pre><code> {"ranks":[{"time":"3","id":"tiago"},
             {"time":"40","id":"fhddhf"},
             {"time":"10","id":"bla"}]}
  </code></pre>