Closed jixam closed 1 year ago
Here is a small application that shows how this is a problem for us: JSON built from a template is garbled unless we set MOJO_NO_JSON_XS=1
.
use Mojolicious::Lite -signatures;
get '/smile.json' => sub ($c) {
my $smile = $c->render_to_string('smile', format => 'text');
$c->render( json => { smile => $smile } );
};
app->start;
__DATA__
@@ smile.text.ep
<%= "\x{1f603}" %>
I have traced the problem into Cpanel::JSON::XS
: https://github.com/rurban/Cpanel-JSON-XS/issues/210
It can be worked around in Mojo::ByteStream
by adding a TO_JSON
method:
sub TO_JSON { shift->to_string }
... but I guess you prefer waiting for an upstream fix?
upstream fix coming today...
Cpanel::JSON::XS Update released. Should work now
Verified working with Cpanel::JSON::XS 4.35.
Steps to reproduce the behavior
Expected behavior
I expected the output to be unaffected by the
MOJO_NO_JSON_XS
setting.Actual behavior
Double UTF-8 encoding of
Mojo::ByteStream
withMOJO_NO_JSON_XS=0
.