Commits

Bryan O'Sullivan committed 15af734

Properly encode NaN and Infinity.

This used to be handled by the blaze-textual package, but that made no sense.

Comments (0)

Files changed (1)

Data/Aeson/Encode.hs

 
 fromNumber :: Number -> Builder
 fromNumber (I i) = integral i
-fromNumber (D d) = double d
+fromNumber (D d)
+    | isNaN d || isInfinite d = "null"
+    | otherwise               = double d
 
 -- | Efficiently serialize a JSON value as a lazy 'L.ByteString'.
 encode :: ToJSON a => a -> L.ByteString