use warnings FATAL => 'all';
use base qw(Exporter);
-our $VERSION = '1.003009';
-$VERSION = eval $VERSION;
+our $VERSION = '1.004001';
+$VERSION =~ tr/_//d;
sub _choose_json_module {
return 'Cpanel::JSON::XS' if $INC{'Cpanel/JSON/XS.pm'};
- return 'JSON::XS' if $INC{'JSON/XS.pm'};
+ return 'JSON::XS' if $INC{'JSON/XS.pm'} && eval { JSON::XS->VERSION(3.0); 1 };
my @err;
return 'Cpanel::JSON::XS' if eval { require Cpanel::JSON::XS; 1; };
push @err, "Error loading Cpanel::JSON::XS: $@";
- return 'JSON::XS' if eval { require JSON::XS; 1; };
+ return 'JSON::XS' if eval { require JSON::XS; JSON::XS->VERSION(3.0); 1; };
push @err, "Error loading JSON::XS: $@";
return 'JSON::PP' if eval { require JSON::PP; 1 };
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);
a class method like the other interfaces; it must be called as a function, with
no invocant. It supports the representation used in all JSON backends.
+Available since version 1.002004.
+
=head1 CONSTRUCTOR
=head2 new
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