Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON::SL doesn't seem to handle all Unicode characters properly. #4

Open
manas12 opened this issue Feb 9, 2017 · 0 comments
Open

Comments

@manas12
Copy link

manas12 commented Feb 9, 2017

I have large JSON files to parse and JSON::SL seemed like the perfect package to do my task. However I noticed that not all unicode characters are being handled properly. Example:

#!/usr/bin/env perl
use 5.016; use warnings;

use utf8;
use JSON::SL;
use JSON;
binmode STDOUT, ':encoding(UTF-8)';

my $str = '{"key":["\u00af"]}';
open my $fh, '<', \$str;

my $data = decode_json($str);
say $_ for @{$data->{key}};

my $j = JSON::SL->new();
$j->set_jsonpointer(['/key/^']);

while( read $fh, my $buf, 1024 ) {
    $j->feed($buf);
    while (my $obj = $j->fetch) {
        my $val = $obj->{Value};
        say $val;
    }
}


$ perl test.pl
¯
"\x{00af}" does not map to utf8 at test.pl line 22.
\xAF

JSON seems to recognize the character, while JSON::SL does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant