Skip to content

Commit

Permalink
Add missing null handling:
Browse files Browse the repository at this point in the history
  • Loading branch information
tolysz committed Dec 12, 2015
1 parent 4de5a20 commit d12fbe5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Data/Aeson/Types/Instances.hs
Expand Up @@ -1604,9 +1604,10 @@ obj .: key = case H.lookup key obj of
-- value are mandatory, use '(.:)' instead.
(.:?) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
obj .:? key = case H.lookup key obj of
Nothing -> pure Nothing
Just v -> modifyFailure addKeyName
$ Just <$> parseJSON v <?> Key key
Nothing -> pure Nothing
Just Null -> pure Nothing
Just v -> modifyFailure addKeyName
$ Just <$> parseJSON v <?> Key key
where
addKeyName = (("failed to parse field " <> unpack key <> ": ") <>)
{-# INLINE (.:?) #-}
Expand Down

0 comments on commit d12fbe5

Please sign in to comment.