moritz / json

A tiny JSON parser and emitter for Perl 6 on Rakudo
A JSON parser and emitter for Perl 6 on Rakudo
76 stars 16 forks source link

Fails to decode JSON #24

Closed zoffixznet closed 7 years ago

zoffixznet commented 7 years ago

This sample sent to me by GitHub's Gist API fails to be decoded: http://temp.perl6.party/Broken.json

01:16   phatbot star: use LWP::Simple; use JSON::Tiny; say (from-json LWP::Simple.get: 'http://temp.perl6.party/Broken.json')<id>
01:16   camelia star-m 2016.10: OUTPUT«Input (4071 characters) is not a valid JSON string␤  in sub from-json at /home/camelia/star-2016.10/share/perl6/site/so​urces/9B467EEF9267A777BB53BAA2F19BE2C9D756BEED (JSON::Tiny) line 59␤  in block <unit> at <tmp> line 1␤␤»

But succeeds with JSON::Fast and Perl 5's JSON::Meth, so I suspect there's nothing wrong with that JSON.

moritz commented 7 years ago

Golf'd:

use v6;
use lib 'lib';
use JSON::Tiny;
for 0x80..0x9f {
    say .base(16), "  ", .uniname;
    from-json(qq["{.chr}"]);
}

Output:

80  
81  
82  BREAK PERMITTED HERE
83  NO BREAK HERE
84  
85  NEXT LINE (NEL)
Input (3 characters) is not a valid JSON string
  in sub from-json at /home/moritz/p6/json/lib/JSON/Tiny.pm (JSON::Tiny) line 59
  in block <unit> at bar.pl line 6
moritz commented 7 years ago

Fixed in 4b5bff11c39cccb723a9141578ee3fe1f2fb5b44. Thanks for the report, @zoffixznet!