| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 |  | 
| 2 use strict; |  | 
| 3 use Test::More; |  | 
| 4 BEGIN { plan tests => 3 }; |  | 
| 5 |  | 
| 6 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; } |  | 
| 7 |  | 
| 8 use JSON -convert_blessed_universally; |  | 
| 9 |  | 
| 10 |  | 
| 11 my $obj  = Test->new( [ 1, 2, {foo => 'bar'} ] ); |  | 
| 12 |  | 
| 13 $obj->[3] = Test2->new( { a => 'b' } ); |  | 
| 14 |  | 
| 15 my $json = JSON->new->allow_blessed->convert_blessed; |  | 
| 16 |  | 
| 17 is( $json->encode( $obj ), '[1,2,{"foo":"bar"},"hoge"]'  ); |  | 
| 18 |  | 
| 19 $json->convert_blessed(0); |  | 
| 20 |  | 
| 21 is( $json->encode( $obj ), 'null' ); |  | 
| 22 |  | 
| 23 $json->allow_blessed(0)->convert_blessed(1); |  | 
| 24 |  | 
| 25 is( $json->encode( $obj ), '[1,2,{"foo":"bar"},"hoge"]'  ); |  | 
| 26 |  | 
| 27 |  | 
| 28 package Test; |  | 
| 29 |  | 
| 30 sub new { |  | 
| 31     bless $_[1], $_[0]; |  | 
| 32 } |  | 
| 33 |  | 
| 34 |  | 
| 35 |  | 
| 36 package Test2; |  | 
| 37 |  | 
| 38 sub new { |  | 
| 39     bless $_[1], $_[0]; |  | 
| 40 } |  | 
| 41 |  | 
| 42 sub TO_JSON { |  | 
| 43     "hoge"; |  | 
| 44 } |  | 
| 45 |  | 
| OLD | NEW | 
|---|