Group
Extension

Matches 2

Attribute-Boolean ( C/CM/CMS/Attribute-Boolean-v1.0.8.tar.gz, CMS, 2016; MetaCPAN )
Attribute-Boolean/lib/Attribute/Boolean.pm ( view source; MetaCPAN )
xt, it will have the value 0 or 1.
In string context is will have the value "false" or "true".
In JSON, it will correctly return false or true values.

    my $bool : Boolean;
    print $bool;    # "f
xt.

=head2 TO_JSON

Provided that convert_blessed is set on the JSON (or JSON::XS) object,
the variable will correctly convert to JSON true or false.

    my $json = new JSON;
    $json->pretty->conv
ssed;
    my $bool : Boolean;
    my %hash = (
	value => $bool,
	me    => true,
    );
    print $json->encode(\%hash);    # {
				    #     "value" : false,
				    #     "me"    : true
				    # }
	
Attribute-Boolean ( C/CM/CMS/Attribute-Boolean-v1.0.8.tar.gz, CMS, 2016; MetaCPAN )
Attribute-Boolean/lib/Attribute/Boolean/Value.pm ( view source; MetaCPAN )
 do { bless \(my $dummy = 1), __PACKAGE__ };
my $false = do { bless \(my $dummy = 0), __PACKAGE__ };

sub true()  { $true  }
sub false() { $false }

sub TO_JSON($) {
    return $_[0] ? \1 : \0;
}

1;

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.