Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cog (4665)

Journal of cog (4665)

Wednesday May 24, 2006
08:59 AM

Argh... JSON 1.05 is broken...

[ #29694 ]

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 :-)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.