[dancer-users] Dancer2::Plugin to_json

Stefan Hornburg (Racke) racke at linuxia.de
Tue Aug 16 13:59:21 BST 2016


On 08/15/2016 09:38 PM, Hagop "Jack" Bilemjian wrote:
> 
> sub BUILD {
>   my $plugin = shift;
>   my $app    = $plugin->app;
> 
>   $plugin->app->add_route(
>     method => 'get',
>     regexp => qr!/mypagel!,
>     code   => \&myfuncl,
>   );
> 
> Then, in sub myfunc {  I want to call to_json.  Right now, I'm doing a use JSON, and it works properly.  Is there a way
> to call the serialozer from the app like $app->to_json?  What is recommended?
> 
> Thanks,    
> 
> Jack

Hello Jack,

there is a simple answer in the manual:

https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Manual.pod#send_as

Regards
	Racke

-- 
Ecommerce and Linux consulting + Perl and web application programming.



More information about the dancer-users mailing list