-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utility functions to extend Aeson -- -- Utility functions to extend Aeson @package json-extra @version 0.1.0.1 -- | Utilities to extend Aeson's parsing functionality. module Data.Aeson.ParseUtils -- | Like fromJSON, but takes a default object and merges it with -- the parsed JSON before decoding into a typed value. fromJSONWithDefaults :: (ToJSON a, FromJSON a) => a -> Value -> Result a -- | 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 mergeValues :: Value -> Value -> Value -- | Like decode, but takes a defaul object and merges it with the -- parsed JSON before decoding. decodeWithDefaults :: (ToJSON a, FromJSON a) => a -> ByteString -> Maybe a -- | Create more idiomatic JSON/YAML representations of lens-enabled or -- plain record types using deriveJSON. -- --
-- data Foobar =
-- Foobar
-- { _foobarSnickerSnack :: Int
-- , _foobarTumTumTree :: String
-- }
--
-- $(deriveLensJSON ''Foobar)
--
-- foobar = Foobar 23 "Hello, world!"
--
--
-- ...encodes to:
--
--
-- {"snicker-snack":23,"tum-tum-tree":"Hello, world!"}
--
module Data.Aeson.DeriveUtils
-- | A drop-in replacement for deriveJSON with options suitable for
-- record fields designed for makeLenses. Constructor names are
-- converted to lowercase-with-dashes; for field names, a
-- leading underscore and the record prefix is stripped off, and then the
-- same conversion to lowercase-with-dashes is performed.
deriveLensJSON :: Name -> Q [Dec]
-- | Same as deriveLensJSON, but allows for different separator
-- characters than - (the typical alternative choice being
-- _).
deriveLensJSON' :: Char -> Name -> Q [Dec]
-- | Options for deriveJSON as used by deriveLensJSON. Use
-- this with deriveJSON to get more control over deriving.
lensJSONOptions :: Options
-- | Options for deriveJSON as used by deriveLensJSON'. Use
-- this with deriveJSON to get more control over deriving.
lensJSONOptions' :: Char -> Options
-- | Build a dashed name from a record constructor name, e.g.
-- FoobarBaz -> foobar-baz.
ctorToDashedIdentifier :: Char -> [Char] -> [Char]
-- | Build a dashed name from a record field name, e.g.
-- _foobarBazQuux -> baz-quux.
recordToDashedIdentifier :: Char -> [Char] -> [Char]
-- | Helper that converts a camel-cased (somethingLikeThis) or
-- pascal-cased (SomethingLikeThis) into all-lowercase with
-- separators, e.g. something-like-this.
camelToDashed :: Char -> [Char] -> [Char]
-- | Strip record prefixes off a typical record field identifier. The
-- prefix is assumed to be everything up to the first uppercase character
-- in the identifier.
stripRecordPrefix :: [Char] -> [Char]