RFC 4627 section 2.4 forbids encoding of NaN and +/- Infinity.
commita52ccd0138c460c295fe4ca3d946f9ab1376f574
authorBryan O'Sullivan <bos@mailrank.com>
dateWed 13 Apr 2011, 09:40 (16 years ago)
parent31a64d1
Data/Aeson/Encode/Double.hs+1−3
@@ -28,9 +28,7 @@ data T = T [Int] {-# UNPACK #-} !Int
2828
2929double :: Double -> Builder
3030double f
31− | isNaN f = fromByteString "NaN"
32− | isInfinite f = fromByteString $
33− if f < 0 then "-Infinity" else "Infinity"
31+ | isNaN f || isInfinite f = fromByteString "null"
3432 | f < 0 || isNegativeZero f = minus `mappend` goGeneric (floatToDigits (-f))
3533 | otherwise = goGeneric (floatToDigits f)
3634 where