From: Mike Rylander Date: Tue, 3 Dec 2013 14:57:39 +0000 (-0500) Subject: LP#1257264: Use the built-in JSON-y test for bools X-Git-Tag: osrf_rel_2_3_0-beta~7^2~7 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9a367d3621706693445b945b283d54281d6dfa0a;p=OpenSRF.git LP#1257264: Use the built-in JSON-y test for bools This removes a dependency on internal details of JSON::XS's implementation of Boolean types which changed with the release of JSON::XS 3.0. Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Jeff Godin --- diff --git a/src/perl/lib/OpenSRF/Utils/JSON.pm b/src/perl/lib/OpenSRF/Utils/JSON.pm index 58a7a02..a83e9d1 100644 --- a/src/perl/lib/OpenSRF/Utils/JSON.pm +++ b/src/perl/lib/OpenSRF/Utils/JSON.pm @@ -160,13 +160,13 @@ sub JSONObject2Perl { # is a hash, but no class marker; simply revivify innards for my $k (keys %$obj) { $obj->{$k} = $pkg->JSONObject2Perl($obj->{$k}) - unless ref $obj->{$k} eq 'JSON::XS::Boolean'; + unless JSON::XS::is_bool $obj->{$k}; } } elsif ( ref $obj eq 'ARRAY' ) { # not a hash; an array. revivify. for my $i (0..scalar(@$obj) - 1) { $obj->[$i] = $pkg->JSONObject2Perl($obj->[$i]) - unless (ref $obj->[$i] eq 'JSON::XS::Boolean'); + unless JSON::XS::is_bool $obj->[$i]; # FIXME? This does nothing except leave any Booleans in # place, without recursively calling this sub on # them. I'm not sure if that's what's supposed to @@ -205,8 +205,7 @@ sub perl2JSONObject { my ($pkg, $obj) = @_; my $ref = ref $obj; - return $obj unless $ref; - return $obj if $ref eq 'JSON::XS::Boolean'; + return $obj if !$ref or JSON::XS::is_bool $obj; my $jsonobj;