-
-
Save anonymous/e611814ddf9d06e598dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile.PL b/Makefile.PL | |
index b5d5efa..2e5ad73 100644 | |
--- a/Makefile.PL | |
+++ b/Makefile.PL | |
@@ -6,6 +6,7 @@ use warnings; | |
use ExtUtils::MakeMaker; | |
# Pod::Simple 3.09 first shipped with Perl 5.11.2 | |
+# JSON::PP 2.27103 first shipped with Perl 5.13.9 | |
# Time::Local 1.2 first shipped with Perl 5.13.9 | |
# IO::Socket::IP 0.26 first shipped with Perl 5.19.8 | |
WriteMakefile( | |
@@ -33,6 +34,7 @@ WriteMakefile( | |
}, | |
PREREQ_PM => { | |
'IO::Socket::IP' => '0.26', | |
+ 'JSON::PP' => '2.27103', | |
'Pod::Simple' => '3.09', | |
'Time::Local' => '1.2' | |
}, | |
diff --git a/lib/Mojo/JSON.pm b/lib/Mojo/JSON.pm | |
index 6f043e2..6db4e68 100644 | |
--- a/lib/Mojo/JSON.pm | |
+++ b/lib/Mojo/JSON.pm | |
@@ -4,13 +4,14 @@ use Mojo::Base -strict; | |
use B; | |
use Carp 'croak'; | |
use Exporter 'import'; | |
+use JSON::PP (); | |
use Mojo::Util; | |
use Scalar::Util 'blessed'; | |
our @EXPORT_OK = qw(decode_json encode_json false from_json j to_json true); | |
# Booleans | |
-my ($FALSE, $TRUE) = map { bless \(my $dummy = $_), 'Mojo::JSON::_Bool' } 0, 1; | |
+my ($FALSE, $TRUE) = (JSON::PP::false, JSON::PP::true); | |
# Escaped special character map (with u2028 and u2029) | |
my %ESCAPE = ( | |
@@ -240,7 +241,7 @@ sub _encode_value { | |
# True or false | |
return $$value ? 'true' : 'false' if $ref eq 'SCALAR'; | |
- return $value ? 'true' : 'false' if $ref eq 'Mojo::JSON::_Bool'; | |
+ return $value ? 'true' : 'false' if $ref eq 'JSON::PP::Boolean'; | |
# Blessed reference with TO_JSON method | |
if (blessed $value && (my $sub = $value->can('TO_JSON'))) { | |
@@ -277,10 +278,6 @@ sub _throw { | |
die "$context\n"; | |
} | |
-# Emulate boolean type | |
-package Mojo::JSON::_Bool; | |
-use overload '""' => sub { ${$_[0]} }, fallback => 1; | |
- | |
1; | |
=encoding utf8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment