Bumping version to 1.004001
[p5sagit/JSON-MaybeXS.git] / lib / JSON / MaybeXS.pm
index 64d13f2..479650e 100644 (file)
@@ -4,19 +4,19 @@ use strict;
 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 };
@@ -29,6 +29,9 @@ sub _choose_json_module {
 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);
@@ -202,6 +205,8 @@ Since this is a bare sub in the various backend classes, it cannot be called as
 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
@@ -229,6 +234,14 @@ To include JSON-aware booleans (C<true>, C<false>) in your data, just do:
     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