 <p>Remove the curly braces from around <code>\@labs</code> - they're converting the array you've created into an anonymous hash before passing it to <code>to_json</code>:</p> <pre><code>#!/usr/bin/perl -w use JSON -support_by_pp; use strict; my @labs = (); push (@labs, {id=&gt;'1', title=&gt;'Lab1'}); push (@labs, {id=&gt;'2', title=&gt;'Lab2'}); my $json_text = to_json \@labs, {ascii=&gt;1, pretty =&gt; 1}; print $json_text; </code></pre> <p>output:</p> <pre><code>[ { "title" : "Lab1", "id" : "1" }, { "title" : "Lab2", "id" : "2" } ] </code></pre>