on master help sign in
Make the comment on `.:!` more accurate.

`.:!` won't necessarily fail of the value its given is `Null`, rather it will attempt to parse it like any other value. Also: touch up the comment on `.:?` slightly.

commit45d241bfe729480c52d4d527570129bbb8c6bf50 authorIan Grant Jeffries <ian@housejeffries.com> dateTue 13 Sep 2016, 18:39 (10 years ago) parentd8dafae
1 file changed+9−5
Data/Aeson/Types/FromJSON.hs+9−5
Data/Aeson/Types/FromJSON.hs+9−5
@@ -655,9 +655,9 @@ obj .: key = case H.lookup key obj of
655655 Just v -> parseJSON v <?> Key key
656656{-# INLINE (.:) #-}
657657
658−-- | Retrieve the value associated with the given key of an 'Object'. The
659−-- result is 'Nothing' if the key is not present or value is 'Null', or 'empty'
660−-- if the value cannot be converted to the desired type.
658+-- | Retrieve the value associated with the given key of an 'Object'. The
659+-- result is 'Nothing' if the key is not present or if its value is 'Null',
660+-- or 'empty' if the value cannot be converted to the desired type.
661661--
662662-- This accessor is most useful if the key and value can be absent
663663-- from an object without affecting its validity. If the key and
@@ -668,8 +668,12 @@ obj .:? key = case H.lookup key obj of
668668 Just v -> parseJSON v <?> Key key
669669{-# INLINE (.:?) #-}
670670
671−-- | Like '.:?', but the resulting parser will fail,
672−-- if the key is present but is 'Null'.
671+-- | Retrieve the value associated with the given key of an 'Object'.
672+-- The result is 'Nothing' if the key is not present or 'empty' if the
673+-- value cannot be converted to the desired type.
674+--
675+-- This differs from '.:?' by attempting to parse 'Null' the same as any
676+-- other JSON value, instead of interpreting it as 'Nothing'.
673677(.:!) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
674678obj .:! key = case H.lookup key obj of
675679 Nothing -> pure Nothing