JSON numbers are not equivalent to JavaScript/ECMAScript numbers, even if they are nominally related; the key differences are that in JSON, numeric literals: (a) can have any non-zero number of digits, effectively making JSON numbers both unbounded and arbitrarily precise (though actual infinities cannot be represented); and (b) cannot represent values that are not composed of digits, like NaN. For that reason, most standard (fixed size/binary) numeric types like double are a poor choice to contain numeric values specified in JSON; in particular, the mismatch means that conversion can be lossy in both directions. Hope that helps! Alvaro On Tue, Apr 24, 2012 at 5:19 PM, Jeremy Shaw <jeremy@n-heptane.com> wrote:
Hello,
I could be wrong, but I think the only real numeric type in javascript is 'Number' which is a floating point number? Which is why Aeson and others insist on converting everything to a Double or other Rational number?
- jeremy
On Tue, Apr 24, 2012 at 3:46 PM, Jeff Shaw <shawjef3@msu.edu> wrote:
Hello, Up until now I've been using Aeson, but I've found that its number type isn't going to work for me. I need to use decimal numbers while avoiding conversions from and to Double, which Aeson doesn't allow. There are quite a few more JSON libraries for Haskell, which all appear to use Rational for numbers, so I'm wondering if anyone can recommend one.
Thanks, Jeff
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe