[Dancer-users] How to un-prettify JSON?
Mr. Puneet Kishor
punk.kish at gmail.com
Sun Mar 13 18:15:11 CET 2011
On Mar 13, 2011, at 8:19 AM, Alastair Sherringham wrote:
> On 13 March 2011 09:29, Alastair Sherringham <sherringham at gmail.com> wrote:
>> set serializer => 'JSON';
>> get '/products' => sub {
>> return db_products();
>> };
>
> If I replace the above with :
>
> get '/products' => sub {
> my $product_list = db_products();
> content_type 'application/json';
> return to_json($product_list,{ pretty => 0});
> };
>
> It works - non-pretty-printed JSON.
>
> This is actually documented in Dancer.pm (to_json section) :
>
> http://search.cpan.org/dist/Dancer/lib/Dancer.pm#to_json_%28$structure,_%options%29
>
> So, my error on missing that.
> ..
Oh! fantastic! I would venture that the above is "hidden" in the documentation. Adding your text above to the documentation would be even more clear and explicit -- clear and explicit instructions are always better than hidden and implicit instructions.
Many thanks for the investigation.
Puneet.
More information about the Dancer-users
mailing list