From 9a367d3621706693445b945b283d54281d6dfa0a Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 3 Dec 2013 09:57:39 -0500 Subject: [PATCH 1/1] 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 --- src/perl/lib/OpenSRF/Utils/JSON.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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; -- 2.43.2