somekindafreak has asked for the wisdom of the Perl Monks concerning the following question:
the output is {"5.0" : 5}. I need {"5.0" : "5.0" } I've spent a ton of time searching the documentation and experimenting without finding a solution. There is a blurb on stringifying a value by wrapping it in quotes or adding a trailing ."" but neither do the trick. It also strips leading zeros while maintaining the float value, 5.10 becomes 5.1my $json=JSON->new->allow_nonref; my $var='5.0'; print $json->encode( { $var => $var } );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can I prevent JSON encode from converting values
by Your Mother (Archbishop) on Jul 20, 2012 at 21:06 UTC | |
by somekindafreak (Acolyte) on Jul 20, 2012 at 22:14 UTC | |
by tobyink (Canon) on Jul 20, 2012 at 22:57 UTC | |
by somekindafreak (Acolyte) on Jul 20, 2012 at 23:16 UTC | |
|
Re: Can I prevent JSON encode from converting values
by aitap (Curate) on Jul 20, 2012 at 19:01 UTC | |
|
Re: Can I prevent JSON encode from converting values
by Anonymous Monk on Jul 20, 2012 at 19:46 UTC | |
by tobyink (Canon) on Jul 20, 2012 at 22:55 UTC |