Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 84321
Status: resolved
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: simon.price [...] bristol.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.53
Fixed in: (no value)



Subject: incorrect serialisation of numeric arrays
JSON->new->encode a Perl array of numbers and then JSON->new->decode it will return the first element of the array as a string, while the rest of the array correctly stays as numbers. [1,2,3] becomes ["1",2,3] Obviously this breaks round trip serialisation/deserialisation. I suspect that this may be due to JSON triggering an implicit type conversion when peeking at the first value in the array - perhaps in a string comparison operator (e.g. eq), which will quietly change the type from numeric to string. ---------- Perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64
From: simon.price [...] bristol.ac.uk
Sorry - this report is incorrect. This bug does not exist. The issue turned out to be an error in my own code. Please close/reject this ticket. Apologies On Sun Mar 31 12:45:46 2013, https://simonprice.myopenid.com/ wrote: Show quoted text
> JSON->new->encode a Perl array of numbers and then JSON->new->decode > it will return the first element of the array as a string, while > the rest of the array correctly stays as numbers. > > [1,2,3] becomes ["1",2,3] > > Obviously this breaks round trip serialisation/deserialisation. > > I suspect that this may be due to JSON triggering an implicit type > conversion when peeking at the first value in the array - perhaps > in a string comparison operator (e.g. eq), which will quietly > change the type from numeric to string. > > > ---------- > Perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread- > multi-2level > Darwin Kernel Version 12.3.0: Sun Jan 6 22:37:10 PST 2013; root:xnu- > 2050.22.13~1/RELEASE_X86_64 x86_64
All right, closed.