Bug#566822: decode does not behave as documented

Florian Weimer fweimer at bfk.de
Mon Jan 25 09:15:00 UTC 2010


Package: libjson-xs-perl
Version: 2.270-1
Severity: important

The documentation says this:

       $perl_scalar = $json->decode ($json_text)
           The opposite of "encode": expects a JSON text and tries to parse it,
           returning the resulting simple scalar or reference. Croaks on error.

           JSON numbers and strings become simple Perl scalars. JSON arrays become
           Perl arrayrefs and JSON objects become Perl hashrefs. "true" becomes 1,
           "false" becomes 0 and "null" becomes "undef".

But this example

use JSON::XS ();
use Data::Dumper;
print Dumper(JSON::XS->new->decode('{"test":true}'));

results in the following output:

$VAR1 = {
          'test' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' )
        };

Expected output, based on the documentation, is:

$VAR1 = {
          'test' => 1
        };

-- 
Florian Weimer                <fweimer at bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99





More information about the pkg-perl-maintainers mailing list