documentation for unblessed_bool is incorrect/outdated
karenetheridge opened this issue · comments
The documentation says:
$json = $json->unblessed_bool ([$enable])
$enabled = $json->get_unblessed_bool
$json = $json->unblessed_bool([$enable])
If $enable is true (or missing), then "decode" will return Perl non-object boolean variables (1 and 0) for JSON booleans ("true" and "false"). If $enable is false, then "decode" will return "Cpanel::JSON::XS::Boolean"
objects for JSON booleans.
This is not correct:
- blessed booleans are JSON::PP::Boolean objects now, not Cpanel::JSON::XS::Boolean
2. unblessed_bool defaults to false.
: $; perl -MData::Dumper -MCpanel::JSON::XS -wle'print Dumper(Cpanel::JSON::XS->new->unblessed_bool->decode("[true]"))'
$VAR1 = [
1
];
: $; perl -MData::Dumper -MCpanel::JSON::XS -wle'print Dumper(Cpanel::JSON::XS->new->unblessed_bool(0)->decode("[true]"))'
$VAR1 = [
bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )
];
: $; perl -MData::Dumper -MCpanel::JSON::XS -wle'print Dumper(Cpanel::JSON::XS->new->decode("[true]"))'
$VAR1 = [
bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )
];
The "or missing" does not indicate the default, it indicates that it will set the option true if you call it without passing a value (like the others).
Oops, thanks.
Fixed with the PR #164