Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utilities to extend Aeson's parsing functionality.
- fromJSONWithDefaults :: (ToJSON a, FromJSON a) => a -> Value -> Result a
- mergeValues :: Value -> Value -> Value
- decodeWithDefaults :: (ToJSON a, FromJSON a) => a -> ByteString -> Maybe a
Documentation
fromJSONWithDefaults :: (ToJSON a, FromJSON a) => a -> Value -> Result a Source
Like fromJSON
, but takes a default object and merges it with the parsed
JSON before decoding into a typed value.
mergeValues :: Value -> Value -> Value Source
Helper function to perform a deep merge on two JSON Value
s. The merging
semantics are defined as such:
1. If both values are objects, they are merged; collisions are resolved
recursively.
2. If either value is null
, the other takes precedence
3. Otherwise, the second value takes precedence
decodeWithDefaults :: (ToJSON a, FromJSON a) => a -> ByteString -> Maybe a Source
Like decode
, but takes a defaul object and merges it with the
parsed JSON before decoding.