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;