Commits

Bryan O'Sullivan committed 42c51bd

Ensure that we parse null as NaN when expecting a floating point number.

Comments (0)

Files changed (1)

     parseJSON (Number n) = case n of
                              D d -> pure d
                              I i -> pure (fromIntegral i)
+    parseJSON Null       = pure (0/0)
     parseJSON v          = typeMismatch "Double" v
     {-# INLINE parseJSON #-}
 
 
 instance FromJSON Number where
     parseJSON (Number n) = pure n
+    parseJSON Null       = pure (D (0/0))
     parseJSON v          = typeMismatch "Number" v
     {-# INLINE parseJSON #-}
 
     parseJSON (Number n) = case n of
                              D d -> pure . fromRational . toRational $ d
                              I i -> pure (fromIntegral i)
+    parseJSON Null       = pure (0/0)
     parseJSON v          = typeMismatch "Float" v
     {-# INLINE parseJSON #-}