Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 52847
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.16
Fixed in: (no value)



Subject: Object state stored in globals
Some of the parser object's state is kept in globals, making it impossible to use two parsers at once. The attached test decodes the same string twice, with different results. Show quoted text
----- BEGIN RESULTS ----- 1..2 ok 1 not ok 2 # Failed test at encapsulation.t line 21. # Structures begin differing at: # $got = 'died with "'"' expected, at character offset 1 (before "foo:"foo"}") at encapsulation.t line 14."' # $expected = HASH(0x9e21af8) # Looks like you failed 1 test of 2. ----- END RESULTS -----
Subject: encapsulation.t
use strict; use warnings; use Test::More tests => 2; BEGIN { $ENV{PERL_JSON_BACKEND} = 'JSON::XS'; } use JSON -support_by_pp; use Data::Dumper; sub test { my ($coder, $str) = @_; my $rv; return $rv if eval { $rv = $coder->decode($str); 1 }; chomp( my $e = $@ ); return "died with \"$e\""; }; my $coder = JSON->new->allow_barekey; for (1..2) { is_deeply( test($coder, q!{foo:"foo"}! ), {foo=>'foo'} ); JSON->new->allow_singlequote(0); }
RT-Send-CC: makamaka [...] cpan.org
Show quoted text
> Some of the parser object's state is kept in globals, making it
> impossible to use two parsers at once.

Using JSON::XS as backend and support_pp option cause this problem.
I will fix it in the next version.

Thanks,

CC: IKEGAMI [...] cpan.org
Subject: Re: [rt.cpan.org #52847] Object state stored in globals
Date: Mon, 4 Jan 2010 11:40:50 -0500
To: bug-JSON [...] rt.cpan.org
From: Eric Brine <ikegami [...] adaelis.com>
On Mon, Jan 4, 2010 at 1:51 AM, Makamaka Hannyaharamitu via RT < bug-JSON@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=52847 > >
> > Some of the parser object's state is kept in globals, making it > > impossible to use two parsers at once.
> > Using JSON::XS as backend and support_pp option cause this problem. > I will fix it in the next version. >
I noticed this problem when trying to produce a patch for RT#52842. My main interest was in fixing RT#52842, but it proved to be far from trivial. I ended up using JSON::PP instead of JSON with -support_by_pp, so these bugs are not affecting me.
RT-Send-CC: makamaka [...] cpan.org
Show quoted text
> I noticed this problem when trying to produce a patch for RT#52842. My main
> interest was in fixing RT#52842, but it proved to be far from trivial. I
> ended up using JSON::PP instead of JSON with -support_by_pp, so these bugs
> are not affecting me.

Sorry, I couldn't help you.
I confirmed RT#52842 will be resolved by this bug fix.

Thanks,