4 BEGIN { plan tests => 3 };
6 BEGIN { $ENV{PERL_JSON_BACKEND} = 1; }
8 use JSON -convert_blessed_universally;
11 skip "can't use JSON::XS.", 3, unless( JSON->backend->is_xs );
13 my $obj = Test->new( [ 1, 2, {foo => 'bar'} ] );
15 $obj->[3] = Test2->new( { a => 'b' } );
17 my $json = JSON->new->allow_blessed->convert_blessed;
19 is( $json->encode( $obj ), '[1,2,{"foo":"bar"},"hoge"]' );
21 $json->convert_blessed(0);
23 is( $json->encode( $obj ), 'null' );
25 $json->allow_blessed(0)->convert_blessed(1);
27 is( $json->encode( $obj ), '[1,2,{"foo":"bar"},"hoge"]' );