Skip Menu |

This queue is for tickets about the JSON-Tiny CPAN distribution.

Report information
The Basics
Id: 95573
Status: resolved
Worked: 20 min
Priority: 0/
Queue: JSON-Tiny

People
Owner: Nobody in particular
Requestors: haarg [...] haarg.org
Cc:
AdminCc:

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



Subject: Strings that have been used as numbers always encoded as numbers
Any string that has been used as a number gets encoded as a number, even for non-numeric strings. my $f = 'foo'; my $d = 0+$f; my $json = JSON::Tiny->new->encode([$f]); # $json is "[0]";
On Mon May 12 06:13:48 2014, haarg wrote: Show quoted text
> Any string that has been used as a number gets encoded as a number, > even for non-numeric strings. > > my $f = 'foo'; > my $d = 0+$f; > my $json = JSON::Tiny->new->encode([$f]); > # $json is "[0]";
Coincidentally (or perhaps not), this issue was addressed in Mojo::JSON within the past 24 hours. The new behavior is that variables that have never been used as strings will be encoded as numbers, *and* in the case of dualvars, strings take precedence unless unless both representations are equivalent. This behavior has now been adopted by JSON::Tiny in version 0.47 and newer. Hopefully it better follows the principle of least surprise.
Resolved in 0.47 as described above.