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