JSON-Parse
view release on metacpan or search on metacpan
lib/JSON/Parse.pod view on Meta::CPAN
use Encode 'decode';
my $input_utf8 = decode ('UTF-16', $input);
my $perl = parse_json ($input_utf8);
or, for a file, use C<:encoding> (see L<PerlIO::encoding> and
L<perluniintro>):
open my $input, "<:encoding(UTF-16)", 'some-json-file';
JSON::Parse does not try to determine the nature of the octet stream
using BOM markers. A BOM marker in the input consists of bytes C<0xFE>
and C<0xFF>, both of which are invalid as UTF-8, and thus will cause a
fatal error.
This restriction to UTF-8 applies regardless of whether Perl thinks
that the input string is a character string or a byte
string. Non-UTF-8 input will cause an L</Unexpected character> error.
The latest specification for JSON, L</RFC 8259>, specifies it to be a
UTF-8 only format.
( run in 0.552 second using v1.01-cache-2.11-cpan-e9daa2b36ef )