Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 52820
Status: resolved
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: IKEGAMI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 2.15
  • 2.16
Fixed in: (no value)



Subject: Relaxed failure with comments at EOF
Hi, According to the documentation, the "relaxed" option causes JSON to treat Perl style comments as whitespace. It fails to do so at end of file. Attached is a test file that demonstrates the problem. Also attached is the results of that test. I'll try to provide a patch tomorrow. - Eric
Subject: comment_at_eof.t
use strict; use warnings; use Test::More tests => 8; use JSON -support_by_pp; use Data::Dumper qw( Dumper ); sub decoder { my ($str) = @_; my $json = JSON->new() ->allow_barekey ->relaxed; $json->incr_parse($_[0]); my $rv; if (!eval { $rv = $json->incr_parse(); 1 }) { $rv = "died with $@"; } local $Data::Dumper::Useqq = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; return Dumper($rv); } is( decoder( "[]" ), '[]', 'array baseline' ); is( decoder( " []" ), '[]', 'space ignored before array' ); is( decoder( "\n[]" ), '[]', 'newline ignored before array' ); is( decoder( "# foo\n[]" ), '[]', 'comment ignored before array' ); is( decoder( "" ), 'undef', 'eof baseline' ); is( decoder( " " ), 'undef', 'space ignored before eof' ); is( decoder( "\n" ), 'undef', 'newline ignored before eof' ); is( decoder( "# foo\n" ), 'undef', 'comment ignored before eof' );
Subject: test_results.txt
1..8 ok 1 - array baseline ok 2 - space ignored before array ok 3 - newline ignored before array ok 4 - comment ignored before array ok 5 - eof baseline ok 6 - space ignored before eof ok 7 - newline ignored before eof not ok 8 - comment ignored before eof # Failed test 'comment ignored before eof' # at comment_at_eof.t line 41. # got: '"died with malformed JSON string, neither array, object, number, string or atom, at character offset 6 (before \"(end of string)\") at comment_at_eof.t line 21.\n"' # expected: 'undef' # Looks like you failed 1 test of 8.
Show quoted text
> I'll try to provide a patch tomorrow.
Attached.
Download diff
application/octet-stream 2k

Message body not shown because it is not plain text.

On Wed Dec 16 15:29:08 2009, ikegami wrote: Show quoted text
> > I'll try to provide a patch tomorrow.
> > Attached.
That patch accidentally made decode("null") stop returning an error when ->allow_nonref(0) This is fixed by the new patch (attached).
Download diff
application/octet-stream 2.2k

Message body not shown because it is not plain text.

RT-Send-CC: makamaka [...] cpan.org
I tried your test and understood the problem.
The No.8 error message shows a fail of JSON::XS.
JSON::PP fails 6-8 tests.

I'm going to send your bug report to JSON::XS author.
So please wait a while for this bug fix.

Thanks,

resloved in version 2.17 Thanks,