Commits

Bryan O'Sullivan committed bc9eb4e

RFC 4627 section 2.4 forbids encoding of NaN and +/- Infinity.

Comments (0)

Files changed (1)

Data/Aeson/Encode/Double.hs

 
 double :: Double -> Builder
 double f
-    | isNaN f                   = fromByteString "NaN"
-    | isInfinite f              = fromByteString $
-                                  if f < 0 then "-Infinity" else "Infinity"
+    | isNaN f || isInfinite f   = fromByteString "null"
     | f < 0 || isNegativeZero f = minus `mappend` goGeneric (floatToDigits (-f))
     | otherwise                 = goGeneric (floatToDigits f)
   where