-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Quick JSON extractions with Aeson -- -- DSL on top of Aeson. This library is experimental. @package aeson-quick @version 0.1.3 module Data.Aeson.Quick -- | Extracts instances of FromJSON from a Value -- -- This is a wrapper around extract which does the actual work. -- -- Examples assume FromJSON Foo and FromJSON Bar. -- -- Extract key from object: -- --
-- >>> value .? "{key}" :: Maybe Foo
--
--
-- Extract list of objects:
--
--
-- >>> value .? "[{key}]" :: Maybe [Foo]
--
--
-- Extract with optional key:
--
--
-- >>> value .? "{key,opt?}" :: Maybe (Foo, Maybe Bar)
--
(.?) :: FromJSON a => Value -> Structure -> Maybe a
-- | Unsafe version of .?. Returns error on failure.
(.!) :: FromJSON a => Value -> Structure -> a
-- | The Parser that executes a Structure against a
-- Value to return an instance of FromJSON.
extract :: FromJSON a => Structure -> Value -> Parser a
-- | Turns data into JSON objects.
--
-- This is a wrapper around build which does the actual work.
--
-- Build a simple Value:
--
--
-- >>> encode $ "{a}" .% True
-- {\"a\": True}
--
--
-- Build a complex Value:
--
--
-- >>> encode $ "[{a}]" '.%' [True, False]
-- "[{\"a\":true},{\"a\":false}]"
--
(.%) :: ToJSON a => Structure -> a -> Value
-- | Executes a Structure against provided data to update a
-- Value.
--
-- Note: Still has undefined behaviours, not at all stable.
build :: ToJSON a => Structure -> Value -> a -> Value
data Structure
Obj :: [(Text, Bool, Structure)] -> Structure
Arr :: Structure -> Structure
Val :: Structure
-- | Parse a structure, can fail
parseStructure :: Text -> Either String Structure
instance GHC.Generics.Generic Data.Aeson.Quick.Structure
instance GHC.Classes.Ord Data.Aeson.Quick.Structure
instance GHC.Classes.Eq Data.Aeson.Quick.Structure
instance Control.DeepSeq.NFData Data.Aeson.Quick.Structure
instance Data.String.IsString Data.Aeson.Quick.Structure
instance GHC.Show.Show Data.Aeson.Quick.Structure