-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Quick JSON extractions with Aeson -- -- Small DSL on top of Aeson for casual and concise JSON construction and -- deconstruction. @package aeson-quick @version 0.2.0 module Data.Aeson.Quick.Internal data Bounds All :: Bounds Single :: Int -> Bounds Range :: Int -> Maybe Int -> Bounds instance GHC.Show.Show Data.Aeson.Quick.Internal.Bounds instance GHC.Generics.Generic Data.Aeson.Quick.Internal.Bounds instance GHC.Classes.Ord Data.Aeson.Quick.Internal.Bounds instance GHC.Classes.Eq Data.Aeson.Quick.Internal.Bounds instance Control.DeepSeq.NFData Data.Aeson.Quick.Internal.Bounds 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 -> Quick -> Maybe a
-- | Unsafe version of .?. Returns error on failure.
(.!) :: FromJSON a => Value -> Quick -> a
-- | The Parser that executes a Quick against a Value
-- to return an instance of FromJSON.
extract :: FromJSON a => Quick -> 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 => Quick -> a -> Value
-- | Executes a Quick against provided data to update a
-- Value.
build :: ToJSON a => Quick -> a -> Either String Value
data Quick
Obj :: [(KeyType, Bool, Quick)] -> Quick
Arr :: Quick -> Bounds -> Quick
Val :: Quick
-- | Parse a structure, can fail
parseQuick :: Text -> Either String Quick
-- | QuasiQuoter for a structure, provides compile time checking ie:
--
--
-- >>> val .! [quick|{foo,bar}|]
--
quick :: QuasiQuoter
jsonlit :: QuasiQuoter
instance GHC.Generics.Generic Data.Aeson.Quick.Quick
instance GHC.Classes.Ord Data.Aeson.Quick.Quick
instance GHC.Classes.Eq Data.Aeson.Quick.Quick
instance Control.DeepSeq.NFData Data.Aeson.Quick.Quick
instance Data.String.IsString Data.Aeson.Quick.Quick
instance GHC.Show.Show Data.Aeson.Quick.Quick