Subject: | decode does not behave as documented |
Date: | Mon, 25 Jan 2010 16:43:51 +0100 |
To: | bug-JSON-XS [...] rt.cpan.org |
From: | gregor herrmann <gregoa [...] debian.org> |
We've resolved the following bug report in the Debian BTS
(http://bugs.debian.org/566822)
Please consider looking into this issue.
Thanks in advance,
gregor, Debian Perl Group
----- Forwarded message from Florian Weimer <fweimer@bfk.de> -----
From: Florian Weimer <fweimer@bfk.de>
To: submit@bugs.debian.org
Subject: Bug#566822: decode does not behave as documented
Date: Mon, 25 Jan 2010 09:15:00 +0000
Reply-To: Florian Weimer <fweimer@bfk.de>, 566822@bugs.debian.org
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@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
Show quoted text
----- End forwarded message -----
--
.''`. http://info.comodo.priv.at/ -- GPG Key IDs: 0x00F3CFE4, 0x8649AA06
: :' : Debian GNU/Linux user, admin, & developer - http://www.debian.org/
`. `' Member of VIBE!AT & SPI, fellow of Free Software Foundation Europe
`- NP: Treibhaus: Colosseum
Message body not shown because it is not plain text.