[dancer-users] Dancer2::Plugin to_json
Hagop "Jack" Bilemjian
jck000 at gmail.com
Tue Aug 16 16:00:34 BST 2016
Hi Stefan,
Thank you very much. That was helpful. Here's the line I placed in my
plugin to make it work:
$app->send_as( JSON => { anchor => $myanchor,
interval => $plugin->update_interval,
text => $output } );
Jack
On Tue, Aug 16, 2016 at 5:59 AM, Stefan Hornburg (Racke) <racke at linuxia.de>
wrote:
> 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.
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20160816/d73e5d11/attachment.html>
More information about the dancer-users
mailing list