BEGIN {
our $JSON_Class = _choose_json_module();
$JSON_Class->import(qw(encode_json decode_json));
+ no strict 'refs';
+ *$_ = $JSON_Class->can($_)
+ for qw(true false);
}
our @EXPORT = qw(encode_json decode_json JSON);
my $true = JSON()->true;
my $false = JSON()->false;
+The booleans are also available as subs or methods on JSON::MaybeXS.
+
+ use JSON::MaybeXS ();
+ my $true = JSON::MaybeXS::true;
+ my $true = JSON::MaybeXS->true;
+ my $false = JSON::MaybeXS::false;
+ my $false = JSON::MaybeXS->false;
+
=head1 CONVERTING FROM JSON::Any
L<JSON::Any> used to be the favoured compatibility layer above the various
JSON() . ': int does not decode to a bool',
);
+is(
+ JSON::MaybeXS::encode_json([JSON::MaybeXS::true]),
+ '[true]',
+ JSON() . ': true sub encodes as correct boolean',
+);
+
+is(
+ JSON::MaybeXS::encode_json([JSON::MaybeXS->true]),
+ '[true]',
+ JSON() . ': true method encodes as correct boolean',
+);
+
+is(
+ JSON::MaybeXS::encode_json([JSON::MaybeXS::false]),
+ '[false]',
+ JSON() . ': false sub encodes as correct boolean',
+);
+
+is(
+ JSON::MaybeXS::encode_json([JSON::MaybeXS->false]),
+ '[false]',
+ JSON() . ': false method encodes as correct boolean',
+);
+
1;