more useful options | |
PerlMonks |
How do I make the JSON module convert true/false to 1/0 instead of a blessed Boolean object?by Cody Fendant (Hermit) |
on Jan 03, 2022 at 03:13 UTC ( [id://11140088]=perlquestion: print w/replies, xml ) | Need Help?? |
Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question: Converting some simple JSON:
and the false value comes out as an object bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ) when converted to Perl data:
Which is a little unsightly and hard to understand as a human. I mean I know it can be tested as a true or false value, but it's much harder to read. What's worse is, the JSON boolean for 'adult' is now $VAR1->{'video'} which means I have to refer to the previous object to even figure out what it is. Not a problem in a small object like this but in a bigger one it will be very frustrating. Is there some way these things can be converted to simple 1 and 0 values? I swear I've read the documentation multiple times and can't see it. Or can I get Data::Dumper to do it for me?
Back to
Seekers of Perl Wisdom
|
|