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@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@dancer.pm
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users