Skip to content

Commit

Permalink
Merge pull request #465 from seagreen/doc-change
Browse files Browse the repository at this point in the history
Make the comment on `.:!` more accurate.
  • Loading branch information
bergmark committed Sep 18, 2016
2 parents 9b774dd + 45d241b commit 388a511
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Data/Aeson/Types/FromJSON.hs
Expand Up @@ -657,9 +657,9 @@ obj .: key = case H.lookup key obj of
Just v -> parseJSON v <?> Key key
{-# INLINE (.:) #-}

-- | Retrieve the value associated with the given key of an 'Object'. The
-- result is 'Nothing' if the key is not present or value is 'Null', or 'empty'
-- if the value cannot be converted to the desired type.
-- | Retrieve the value associated with the given key of an 'Object'. The
-- result is 'Nothing' if the key is not present or if its value is 'Null',
-- or 'empty' if the value cannot be converted to the desired type.
--
-- This accessor is most useful if the key and value can be absent
-- from an object without affecting its validity. If the key and
Expand All @@ -670,8 +670,12 @@ obj .:? key = case H.lookup key obj of
Just v -> parseJSON v <?> Key key
{-# INLINE (.:?) #-}

-- | Like '.:?', but the resulting parser will fail,
-- if the key is present but is 'Null'.
-- | Retrieve the value associated with the given key of an 'Object'.
-- The result is 'Nothing' if the key is not present or 'empty' if the
-- value cannot be converted to the desired type.
--
-- This differs from '.:?' by attempting to parse 'Null' the same as any
-- other JSON value, instead of interpreting it as 'Nothing'.
(.:!) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
obj .:! key = case H.lookup key obj of
Nothing -> pure Nothing
Expand Down

0 comments on commit 388a511

Please sign in to comment.