Subject: | JSON floats broken by long double support |
JSON::Syck does bad things to floating point values, when running on
Perls which have long double as their default float type.
This does not occur for YAML::Syck.
I built a stand-alone copy of Perl with long double support enabled at
Configure time, and have been able to reliably reproduce the problem.
I've pasted a simple test script and example output, below.
Thanks
--Alex
#### File: json-double-test
use strict;
use warnings;
use Config;
print "Arch: $Config{archname}\n";
use YAML::Syck;
use JSON::Syck;
my $loadedYAMLSyck = YAML::Syck::Load("---\ntestFloat: 3.14159265\n");
my $loadedJSONSyck = JSON::Syck::Load("{\"testFloat\":3.14159265}");
print "Loaded YAML (Syck) Value: ". $loadedYAMLSyck->{testFloat} ."\n";
print "Loaded JSON (Syck) Value: ". $loadedJSONSyck->{testFloat} ."\n";
__END__
Produces the following output for me:
# ~/ldperl/bin/perl json-double-test
Arch: x86_64-linux-ld
Loaded YAML (Syck) Value: 3.14159265
Loaded JSON (Syck) Value: 3.14159265000000021
# perl json-double-test
Arch: x86_64-linux
Loaded YAML (Syck) Value: 3.14159265
Loaded JSON (Syck) Value: 3.14159265