perl version 5.18
I am having an issue with the perl JSON encoder and putting quotes around a float.
see sample code:
use JSON;
use Data::Dumper;
my $float = 1.2;
my $t = {
float => $float
};
my $json1 = encode_json($t);
print Dumper $t;
my $json2 = encode_json($t);
print $json1 . "\n";
print $json2 . "\n";
Output:
$VAR1 = {
'float' => '1.2',
'integer' => 1
};
{"float":1.2,"integer":1}
{"float":"1.2","integer":1}
As you can see after using Dumper the JSON encoder adds the quotes. Any ideas why this would happen?
Not in the sample code above, but in production, I can not remove the quotes unless I add .01. Even *= *1 does not work.