title: Perl Dancer - JSON serializer and JSON arrays
body: <p>I have a problem working with the built in Perl <a href="https://en.wikipedia.org/wiki/Dancer_%28software%29" rel="nofollow">Dancer</a> serializer for JSON and JSON arrays.</p>
  
  <p>I activated the serializer in the app.pl file:</p>
  
  <pre><code>#!/usr/bin/env perl
  use Dancer;
  use main;
  
  set serializer =&gt; 'JSON';
  
  dance;
  </code></pre>
  
  <p>In the module itself I tested the JSON parsing like this:</p>
  
  <pre><code>post '/test/' =&gt; sub {
      my $params = request-&gt;params;
  
      debug('Test: ', $params);
  };
  </code></pre>
  
  <p>Now I wanted to make sure the JSON gets parsed as expected, so I tried using <a href="http://en.wikipedia.org/wiki/CURL" rel="nofollow">cURL</a> to understand the way the serializer works:</p>
  
  <pre><code>curl -H "Content-Type: application/json" -X POST http://localhost:3000/test/ -d '{ "Name" : "foo", "email" : "bar" }'
  </code></pre>
  
  <p>The result was as expected:</p>
  
  <pre><code>Test: {'Name' =&gt; 'foo','email' =&gt; 'bar'}
  </code></pre>
  
  <p>But trying to send an array:</p>
  
  <pre><code>curl -H "Content-Type: application/json" -X POST http://localhost:3000/test/ -d '[{ "Name" : "foo", "email" : "bar" }]'
  </code></pre>
  
  <p>Resulted in:</p>
  
  <pre><code>Test: {}
  </code></pre>
  
  <p>I expected the serializer to return an array reference, but it seems like it returns an empty hash. I tried using the serializer the other way around, but encoding JSONs seems to work as expected. What have I done wrong?</p>