Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit ca20520e51d95b265019349399b9c8a4841b5553 1 parent ca13010
@bos bos authored
Showing with 3 additions and 0 deletions.
  1. +3 −0  Data/Aeson/Types.hs
View
3  Data/Aeson/Types.hs
@@ -367,6 +367,7 @@ instance FromJSON Double where
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 #-}
@@ -376,6 +377,7 @@ instance ToJSON Number where
instance FromJSON Number where
parseJSON (Number n) = pure n
+ parseJSON Null = pure (D (0/0))
parseJSON v = typeMismatch "Number" v
{-# INLINE parseJSON #-}
@@ -387,6 +389,7 @@ instance FromJSON Float where
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 #-}
Please sign in to comment.
Something went wrong with that request. Please try again.