[dancer-users] Returning JSON Data

Kadir Beyazlı kadirbeyazli at gmail.com
Mon Sep 14 22:18:18 BST 2015


Hi,

On Mon, Sep 14, 2015 at 5:03 PM, WK <wanradt at gmail.com> wrote:
> 2015-09-14 15:44 GMT+03:00 Kadir Beyazlı <kadirbeyazli at gmail.com>:
>
>> [KB] I checked, it is UTF-8. But my Turkish characters are still
>> broken. My country's character set is iso-8859-9 but UTF8 was always
>> enough to display correct data.
>> I will search about it.
>
> Actually, right way to emit JSON is to use serializer, so the right
> way is something like that:
>
> =======
> use Dancer2;
> set serializer => 'JSON';
>
> get '/json' => sub {
>   my $ref = {
>     BranchID => 'ülane kõnnib öösiti õues',
>     Branch   => 'šaakal kasutab ainult žiletti',
>   };
>   return  $ref;
> };
>
> start;
> =======
>
> If you don't use serializer, you have wrong content-type. If you set
> content-type by hand, you have wrong content-lenght, etc
content-type is text/html at both cases (with and without serializer),
not application/json when i curl url.
But it works
And when I use serializer, other routes fail because other routes
don't return json data.
Even if I define serializer in the route which will return json, it
effects all routes

>
> Wbr,
> --
> Kõike hääd,
>
> Gunnar
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users



-- 
Kadir Beyazlı
Computer Engineer
GSM : +90 535 821 50 00


More information about the dancer-users mailing list