[Dancer-users] How to un-prettify JSON?
Alastair Sherringham
sherringham at gmail.com
Sun Mar 13 14:19:56 CET 2011
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.
Cheers,
--
Alastair Sherringham
http://www.sherringham.net
More information about the Dancer-users
mailing list