Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: how to decode JSON::PP::Boolean

by tangent (Vicar)
on Dec 06, 2017 at 16:46 UTC ( #1205027=note: print w/replies, xml ) Need Help??


in reply to how to decode JSON::PP::Boolean

The value you are retrieving from $decoded2->{HasAttachments} needs to be treated as a true or false value in your code - it does not need further decoding:
use JSON; use Data::Dumper; my $json = encode_json( {HasAttachments => \0} ); # \0 is JSON false my $decoded = decode_json( $json ); print Dumper( $decoded->{HasAttachments} ); if ( $decoded->{HasAttachments} ) { print "HasAttachments is true"; } else { print "HasAttachments is false"; } # Prints: $VAR1 = bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ); HasAttachments is false

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1205027]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-10-17 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (71 votes). Check out past polls.

    Notices?