Skip to content
Browse files

Remove prototype from TO_JSON per https://rt.cpan.org/Public/Bug/Disp…

…lay.html?id=84398

Also documented JSON support.
  • Loading branch information...
1 parent bc156f8 commit 2b6bec74c158cba4fe9fcae72b4bb451139ae16a @ingydotnet committed
Showing with 13 additions and 2 deletions.
  1. +12 −2 lib/boolean.pm
  2. +1 −0 t/json.t
View
14 lib/boolean.pm
@@ -1,6 +1,6 @@
use 5.005003;
package boolean;
-use strict;
+use strict; use warnings;
$boolean::VERSION = '0.29';
@@ -79,7 +79,7 @@ sub truth {
&Internals::SvREADONLY( \ !!1, 1);
}
-sub TO_JSON() { ${$_[0]} ? \1 : \0 }
+sub TO_JSON { ${$_[0]} ? \1 : \0 }
1;
@@ -230,6 +230,16 @@ Prints:
C<-truth> can be used with the other import options.
+=head1 JSON SUPPORT
+
+JSON.pm will encode Perl data with boolean.pm values correctly if you use the
+C<convert_blessed> option:
+
+ use JSON;
+ use boolean -truth;
+ my $json = JSON->new->convert_blessed;
+ say $json->encode({false => (0 == 1)}); # Says: '{"false":false}',
+
=head1 AUTHOR
Ingy döt Net <ingy@cpan.org>
View
1 t/json.t
@@ -1,3 +1,4 @@
+use strict; use warnings;
use Test::More tests => 2;
use boolean -truth;
my $HAVE_JSON = eval { require JSON };

0 comments on commit 2b6bec7

Please sign in to comment.
Something went wrong with that request. Please try again.