Limper::SendJSON - adds a send_json function to Limper
version 0.003
use Limper::SendJSON; use Limper; # this must come after all extensions # some other routes get '/json' = sub { send_json { foo => 'bar' }; }; get '/json-pretty' = sub { send_json { foo => 'bar' }, pretty => 1; }; limp;
Limper::SendJSON extends Limper to easily return JSON, with the proper Content-Type header.
The following are all additionally exported by default:
send_json
Sends the HASH or ARRAY given as JSON. If Content-Type is not already set, it will be set to application/json. Returns 500 if the scalar cannot be encoded by JSON::MaybeXS.
Copyright (C) 2014 by Ashley Willis <ashley+perl@gitable.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.
Limper
Limper::Engine::PSGI
Limper::SendFile
To install Limper::SendJSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Limper::SendJSON
CPAN shell
perl -MCPAN -e shell install Limper::SendJSON
For more information on module installation, please visit the detailed CPAN module installation guide.