Skip Menu |
 

This queue is for tickets about the File-JSON-Slurper CPAN distribution.

Report information
The Basics
Id: 118876
Status: new
Priority: 0/
Queue: File-JSON-Slurper

People
Owner: Nobody in particular
Requestors: skaji [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: write_json does not handle encoding properly
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-32062-1479732147-1744.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 906
Download (untitled) / with headers
text/plain 906b
``` # test.t use strict; use warnings; use utf8; use File::JSON::Slurper 'write_json'; use Test::More; my $ref = { a => 'こんにちは' }; eval { write_json("ref.json", $ref, 'euc-jp') }; ok !$@, "no exception"; done_testing; ``` ``` Show quoted text
> prove test.t
test.t .. 1/? # Failed test 'no exception' # at test.t line 12. # Looks like you failed 1 test of 1. test.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/1 subtests Test Summary Report ------------------- test.t (Wstat: 256 Tests: 1 Failed: 1) Failed test: 1 Non-zero exit status: 1 Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.05 cusr 0.00 csys = 0.07 CPU) Result: FAIL ``` `JSON::MaybeXS::encode_json` equals `JSON::MaybeXS->new->utf8(1)->encode`, so `my $json = encode_json($ref)` is already a UTF-8 encoded, binary string. https://github.com/neilb/File-JSON-Slurper/blob/master/lib/File/JSON/Slurper.pm#L22


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.