Skip Menu |

This queue is for tickets about the JSON-PP CPAN distribution.

Report information
The Basics
Id: 100462
Status: open
Priority: 0/
Queue: JSON-PP

People
Owner: Nobody in particular
Requestors: bwhite [...] ptfs.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug: allow_blessed, convert_blessed, etc. not reentry-safe
Date: Wed, 19 Nov 2014 20:24:20 -0500
To: bug-JSON-PP [...] rt.cpan.org
From: "White, Bill" <bwhite [...] ptfs.com>
JSON allow_blessed, convert_blessed, etc. are not reentry-safe, even when used via OO interface, leading to problems when TO_JSON flattening methods invoke JSON convert functions. Demonstration: use JSON; package Test; use Moose; use Method::Signatures; has 'thing' => ( is => 'rw', isa => 'HashRef' ); method TO_JSON { warn "Flattening"; my $err = JSON->new->encode({x => 1}); return { flat => 1}; } no Moose; package main; use boolean; my $foo = new Test(thing => {foo => 1}); my $bar = false(); my $s = JSON->new->allow_blessed->convert_blessed->encode([$foo, $bar]); print $s;
On Thu Nov 20 10:24:30 2014, bwhite@ptfs.com wrote: Show quoted text
> JSON allow_blessed, convert_blessed, etc. are not reentry-safe, even when > used via OO interface, leading to problems when TO_JSON flattening methods > invoke JSON convert functions. > > Demonstration: > > use JSON; > > package Test; > use Moose; > use Method::Signatures; > > has 'thing' => ( > is => 'rw', > isa => 'HashRef' > ); > > method TO_JSON { > warn "Flattening"; > my $err = JSON->new->encode({x => 1}); > return { flat => 1}; > } > > no Moose; > > package main; > use boolean; > > my $foo = new Test(thing => {foo => 1}); > my $bar = false(); > > my $s = JSON->new->allow_blessed->convert_blessed->encode([$foo, $bar]); > print $s;
Could you elaborate the issue, and show which versions of modules (JSON, JSON::XS, and JSON::PP) you used? The script doesn't show me what is the real problem.