Created
April 1, 2013 09:35
-
-
Save dankogai/5284015 to your computer and use it in GitHub Desktop.
boolean best practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.12; | |
use boolean -truth; | |
use JSON; | |
sub boolean::TO_JSON() { !$_[0] ? \0 : \1 } | |
my $json = JSON->new->convert_blessed; | |
my $bools = { false => ( 0 == 1 ), true => ( 1 == 1 ) }; | |
eval { say encode_json($bools) }; | |
warn $@ if $@; | |
say $json->encode($bools); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment