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.