From: erickson Date: Tue, 17 Feb 2009 18:04:39 +0000 (+0000) Subject: gotta protect the JSONObject2Perl() when decoding arrays as well X-Git-Tag: osrf_rel_2_0_1~398 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5b38d0d929ed398417f5970f7e2fdf8b2a53b674;p=OpenSRF.git gotta protect the JSONObject2Perl() when decoding arrays as well git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1666 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perl/lib/OpenSRF/Utils/JSON.pm b/src/perl/lib/OpenSRF/Utils/JSON.pm index 7b962e1..c37fa1f 100644 --- a/src/perl/lib/OpenSRF/Utils/JSON.pm +++ b/src/perl/lib/OpenSRF/Utils/JSON.pm @@ -80,11 +80,14 @@ sub JSONObject2Perl { return undef; } for my $k (keys %$obj) { - $obj->{$k} = (ref($obj->{$k}) eq 'JSON::XS::Boolean') ? - $obj->{$k} : $class->JSONObject2Perl($obj->{$k}); + $obj->{$k} = $class->JSONObject2Perl($obj->{$k}) + unless ref($obj->{$k}) eq 'JSON::XS::Boolean'; } } elsif( $ref eq 'ARRAY' ) { - $obj->[$_] = $class->JSONObject2Perl($obj->[$_]) for(0..scalar(@$obj) - 1); + for my $i (0..scalar(@$obj) - 1) { + $obj->[$i] = $class->JSONObject2Perl($obj->[$i]) + unless ref($obj->[$i]) eq 'JSON::XS::Boolean'; + } } return $obj; }