I am working with JSON data on a block of product versions. Therefore I want 5.0 to remain as a '5.0' string without being converted to an integer and without adding any token trailing characters. When I run:
my $json=JSON->new->allow_nonref;
my $var='5.0';
print $json->encode( { $var => $var } );
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.1