Here's some sample code:
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use JSON;
my $json = JSON->new();
my $hash = { example => '02' };
print Dumper \$hash;
my $hash_2_json = $json->objToJson($hash);
print Dumper \$hash_2_json;
my $from_json = $json->jsonToObj($hash_2_json);
print Dumper \$from_json;
The output with JSON 1.03:
$VAR1 = \{
'example' => '02'
};
$VAR1 = \'{"example":"02"}';
$VAR1 = \{
'example' => '02'
};
The output with JSON 1.05:
$VAR1 = \{
'example' => '02'
};
$VAR1 = \'{"example":"02"}';
$VAR1 = \{
'example' => 2
};
That leading zero is being lost.
Now, the funny thing was that the guy complaining that my system had a bug would send me an example script to show me the bug, I'd run it and get back to him saying "look, it ain't broken... I'm getting the results I expected..."
Eventually, the guy came up with the theory that we could be running different versions of some module...
Lo and behold: we were.
And JSON 1.05 is broken. I already sent an email to the maintainer :-) Hope to get an answer real soon :-)