in reply to Getting JSON::PP:Boolean value

If I just assign them to another variable they are undef.

Here is the SSCCE your post omitted showing that this is not the case.

use strict; use warnings; use JSON::PP; use Test::More tests => 2; my $in = '{ "z": true, "y": false }'; my $out = decode_json ($in); my $z = $out->{z}; my $y = $out->{y}; is ($z, JSON::PP::true, "z is true" ); is ($y, JSON::PP::false, "y is false" );

Replies are listed 'Best First'.
Re^2: Getting JSON::PP:Boolean value
by stevieb (Canon) on May 24, 2017 at 13:22 UTC

    I 100% concur here that OP is mistaken, and must be doing something wrong. I was working heavily with the JSON objectified bool last week writing my GPS software. Here's an example that illustrates what the json->perl conversion looks like, and the resulting output before/after re-assignment:

    use warnings; use strict; use Data::Dumper; use JSON; my $json = '{"true": true, "false": false}'; my $perl = decode_json $json; print Dumper $perl; my $t = $perl->{true}; my $f = $perl->{false}; print "orig true: $perl->{true}, var true: $t\n"; print "orig false: $perl->{false}, var false: $f\n"; __END__ $VAR1 = { 'false' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ), 'true' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ) }; orig true: 1, var true: 1 orig false: 0, var false: 0