NAME
Limper::SendJSON - adds a send_json function to Limper
VERSION
version 0.003
SYNOPSIS
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;
DESCRIPTION
Limper::SendJSON extends Limper to easily return JSON, with the proper Content-Type header.
EXPORTS
The following are all additionally exported by default:
send_json
FUNCTIONS
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 AND LICENSE
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.