rurban / Cpanel-JSON-XS

Improved fork of JSON-XS

Home Page:http://search.cpan.org/dist/Cpanel-JSON-XS/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

true failure with threads::shared

sbingner opened this issue · comments

I have the below behavior with Cpanel::JSON::XS v 4.19 - the issue is that it returns every boolean value as false.

use Cpanel::JSON::XS qw(encode_json decode_json);
use Data::Dumper;
use threads;
use threads::shared;
use strict;

my $json : shared = shared_clone({'enabled' => Cpanel::JSON::XS::true});

print encode_json($json) . "\n" . Data::Dumper->Dump([$json]) . "\n\n";

output:

{"enabled":false}
$VAR1 = {
          'enabled' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )
        };

But when I try with stock JSON:

use JSON::XS qw(encode_json decode_json);
use Data::Dumper;
use threads;
use threads::shared;
use strict;

my $json : shared = shared_clone({'enabled' => JSON::XS::true});

print encode_json($json) . "\n" . Data::Dumper->Dump([$json]) . "\n\n";

output:

{"enabled":true}
$VAR1 = {
          'enabled' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )
        };

Added a testcase, branch threads-shared

Fixed in master, will be in the upcoming 4.20.
Note: This worked before 4.00, and only got broken with the types work.

Thanks

Note that JSON::PP from 2.9x to 4.0 are broken also. You need to upgrade.