Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by tangent (Parson)
on Dec 06, 2017 at 16:46 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-24 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found