timo / json_fast

a naive imperative json parser in perl6, to evaluate performance against JSON::Tiny
Artistic License 2.0
27 stars 20 forks source link

Passes invalid JSON #66

Closed JJ closed 1 year ago

JJ commented 4 years ago

This JSON:

{ 3 => 3}

Passes without a problem.

This line of code:

https://github.com/timo/json_fast/blob/master/lib/JSON/Fast.pm6#L562

is not reached, and I think it's not tested either.

timo commented 4 years ago

hi, can you verify that this is no longer an issue? { 3 => 3 } isn't valid json map syntax and it already complains as soon as it sees the initial 3 that is not quoted.

JJ commented 4 years ago

I'm afraid this is still an issue with raku 2020.08.2 and the module upgraded to the latest option.

coke commented 1 year ago

Seems OK with more recent versions:

$ raku -MJSON::Fast -e "say from-json '{ 3 => 3}'"
$ raku --version
Welcome to Rakudo™ v2023.02.
Implementing the Raku® Programming Language v6.d.
$ zef info JSON::Fast | grep Identity
- Identity: JSON::Fast:ver<0.17>:auth<cpan:TIMOTIMO>
timo commented 1 year ago

i don't think i was able to reproduce the original issue, but it's been a while so i may be misremembering. anyway, as coke points out, this works fine now


⬢[timo@toolbox json_fast]$ raku -MJSON::Fast -e "say from-json '{ 3 => 3}'"
at 2: json requires object keys to be strings
  in sub parse-obj at /home/timo/raku/prefix/share/perl6/site/sources/C1DA909DAD9BF713751A74EBF038C545A1EA6ECC (JSON::Fast) line 652
  in sub parse-thing at /home/timo/raku/prefix/share/perl6/site/sources/C1DA909DAD9BF713751A74EBF038C545A1EA6ECC (JSON::Fast) line 755
  in sub from-json at /home/timo/raku/prefix/share/perl6/site/sources/C1DA909DAD9BF713751A74EBF038C545A1EA6ECC (JSON::Fast) line 911
  in block <unit> at -e line 1```