Two more problems with Mojolicious
Александр Поволоцкий
tarkhil at over.ru
Mon Mar 4 19:18:59 UTC 2019
Ok, got the issue. It was only valid with chunk_write. I'll replace in
with more common write and see
On 04.03.2019 22:02, Andrey Zelenkov wrote:
>> On 4 Mar 2019, at 19:06, Александр Поволоцкий <tarkhil at over.ru> wrote:
>>
>> My program outputs JSON. decode_json works fine with HTTP, to_json is required for PSGI.
> [..]
>
> Hi Alex,
>
> I’ve tried to use encode_json and to_json and they both work fine.
>
> For encode_json:
>
> ===
> use Mojolicious::Lite;
> use Mojo::JSON qw(decode_json encode_json to_json);
>
> get '/' => sub {
> my $c = shift;
> $c->write(encode_json({test => 'Привет I ♥ Mojolicious!'}));
> };
>
> app->start;
> ===
>
> I've got response:
>
> ===
> HTTP/1.1 200 OK
> Date: Mon, 04 Mar 2019 18:53:21 GMT
> Server: Unit/1.8.0
> Connection: close
> Transfer-Encoding: chunked
>
> 2a
> {"test":"Привет I ♥ Mojolicious!"}
> 0
> ===
>
> and for to_json:
>
> ===
> use Mojolicious::Lite;
> use Mojo::JSON qw(decode_json encode_json to_json);
>
> get '/' => sub {
> my $c = shift;
> $c->write(to_json({test => 'Привет I ♥ Mojolicious!'}));
> };
>
> app->start;
> ===
>
> I've got response:
>
> ===
> HTTP/1.1 200 OK
> Date: Mon, 04 Mar 2019 18:54:24 GMT
> Server: Unit/1.8.0
> Connection: close
> Transfer-Encoding: chunked
>
> 2a
> {"test":"Привет I ♥ Mojolicious!"}
> 0
> ===
>
>
> Could you please provide more information about
> how you try to use to_json?
>
> --
> Andrey Zelenkov
>
>
>
>
>
>
> _______________________________________________
> unit mailing list
> unit at nginx.org
> https://mailman.nginx.org/mailman/listinfo/unit
More information about the unit
mailing list