Subject: | JSON::PC Incorrect conversion of strings that look like octal numbers |
Hi,
JSON::PC doesn't seem to convert quoted values that look like octal
numbers correctly. For example:
[ { 'phone-number' => '02346' } ]
is converted to:
[{"phone-number":02346}]
If this is reparsed we don't get back the original structure. Instead we
get this:
[{'phone-number' => 1254}]
Here is a full example that compares the output from JSON::PC with the
output of JSON:
#!/usr/bin/perl -l
use strict;
use JSON;
use JSON::PC;
use Data::Dumper;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 0;
my $json = JSON->new();
my $json_pc = JSON::PC->new();
my $obj = [ { 'phone-number' => '02346' } ];
my $json_str = $json ->objToJson($obj);
my $json_str_pc = $json_pc->objToJson($obj);
my $perl_str = $json ->jsonToObj($json_str);
my $perl_str_pc = $json_pc->jsonToObj($json_str_pc);
print "JSON version : ", $json->VERSION();
print "JSON::PC version : ", $json_pc->VERSION(), "\n";
print "JSON structure : ", $json_str;
print "JSON structure PC: ", $json_str_pc, "\n";
print "Perl structure : ", Dumper $perl_str;
print "Perl structure PC: ", Dumper $perl_str_pc;
__END__
Prints:
JSON version : 1.07
JSON::PC version : 0.01
JSON structure : [{"phone-number":"02346"}]
JSON structure PC: [{"phone-number":02346}]
Perl structure : [{'phone-number' => '02346'}]
Perl structure PC: [{'phone-number' => 1254}]
JSON::Syck also corresponds to the output of JSON.
Tested with Perl 5.8.7 on linux.
John.
--