NAME
File::Raw::JSON::Boolean - True/false sentinel class for File::Raw::JSON
SYNOPSIS
use File::Raw::JSON::Boolean;
my $t = File::Raw::JSON::Boolean::TRUE;
my $f = File::Raw::JSON::Boolean::FALSE;
print "yes" if $t; # bool overload (XSUB body)
print "$t"; # "1" - stringification overload
print 0 + $f; # 0 - numification overload
DESCRIPTION
Lightweight true/false sentinel class so File::Raw::JSON callers do not need Types::Serialiser or JSON::PP installed just to distinguish JSON booleans from numbers/strings.
The two singletons (returned by "TRUE" and "FALSE") are allocated once in C at module load. Callers should not mutate them; behaviour is undefined if you do.
The four overload entry points (bool, 0+, "", !) are XSUBs registered via the XS OVERLOAD: directive at module-bootstrap time - measurably faster than the equivalent Perl-level overload bodies, which matters when JSON booleans get exercised in tight loops.
The encoder in File::Raw::JSON also recognises objects blessed into JSON::PP::Boolean, Types::Serialiser::Boolean, Cpanel::JSON::XS::Boolean, JSON::XS::Boolean, and the boolean module by name. Booleans round-trip cleanly whichever class they originated from.
CONSTANTS
TRUE
Returns the singleton true sentinel.
FALSE
Returns the singleton false sentinel.
METHODS
is_true / is_false
Class predicates - return 1 if the argument is a sentinel of the matching truth value, 0 otherwise.
LICENSE AND COPYRIGHT
Copyright (c) 2026 LNATION. Artistic License 2.0.