perl - How to enable "pretty" JSON rendering in Mojolicious::Lite? -


simple question. how turn on "pretty" json rendering in mojolicious::lite? i'm developing restful api , see output in bit more human readable format.

you override default json renderer in startup method.

for minimal example:

use json::xs; our $json = json::xs->new->utf8->pretty;  sub startup {   $self = shift;   ...   $self->app->renderer->add_handler(json => sub {       ${$_[2]} = $json->encode($_[3]{json});   }); } 

the default handler defined in mojolicious/renderer.pm , use mojo::json::encode_json.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -