json-extra-0.1.0.1: Utility functions to extend Aeson

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.ParseUtils

Description

Utilities to extend Aeson's parsing functionality.

Synopsis

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 Values. 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.