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
``` # 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