aeson-2.0.3.0: Fast JSON parsing and encoding
Copyright(c) 2011-2016 Bryan O'Sullivan
(c) 2011 MailRank Inc.
LicenseBSD3
MaintainerBryan O'Sullivan <bos@serpentine.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Types.Internal

Description

Types for working with JSON data.

Synopsis

Core JSON types

data Value Source #

A JSON value represented as a Haskell value.

Instances

Instances details
Eq Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(==) :: Value -> Value -> Bool Source #

(/=) :: Value -> Value -> Bool Source #

Data Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Value -> c Value Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Value Source #

toConstr :: Value -> Constr Source #

dataTypeOf :: Value -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Value) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Value) Source #

gmapT :: (forall b. Data b => b -> b) -> Value -> Value Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Value -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Value -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Value -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Value -> m Value Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Value -> m Value Source #

Ord Value Source #

The ordering is total, consistent with Eq instance. However, nothing else about the ordering is specified, and it may change from environment to environment and version to version of either this package or its dependencies (hashable and 'unordered-containers').

Since: 1.5.2.0

Instance details

Defined in Data.Aeson.Types.Internal

Read Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Show Value Source #

Since version 1.5.6.0 version object values are printed in lexicographic key order

>>> toJSON $ H.fromList [("a", True), ("z", False)]
Object (fromList [("a",Bool True),("z",Bool False)])
>>> toJSON $ H.fromList [("z", False), ("a", True)]
Object (fromList [("a",Bool True),("z",Bool False)])
Instance details

Defined in Data.Aeson.Types.Internal

IsString Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Generic Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Associated Types

type Rep Value :: Type -> Type Source #

Methods

from :: Value -> Rep Value x Source #

to :: Rep Value x -> Value Source #

Function Value Source #

Since: 2.0.3.0

Instance details

Defined in Data.Aeson.Types.Internal

Methods

function :: (Value -> b) -> Value :-> b Source #

Arbitrary Value Source #

Since: 2.0.3.0

Instance details

Defined in Data.Aeson.Types.Internal

CoArbitrary Value Source #

Since: 2.0.3.0

Instance details

Defined in Data.Aeson.Types.Internal

Methods

coarbitrary :: Value -> Gen b -> Gen b Source #

NFData Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

rnf :: Value -> () Source #

Hashable Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

FromJSON Value Source # 
Instance details

Defined in Data.Aeson.Types.FromJSON

KeyValue Pair Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Key -> v -> Pair Source #

KeyValue Object Source #

Constructs a singleton KeyMap. For calling functions that demand an Object for constructing objects. To be used in conjunction with mconcat. Prefer to use object where possible.

Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Key -> v -> Object Source #

ToJSON Value Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Lift Value Source #

Since: 0.11.0.0

Instance details

Defined in Data.Aeson.Types.Internal

GToJSON' Value arity (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a -> U1 a -> Value Source #

GToJSON' Value arity (V1 :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a -> V1 a -> Value Source #

GToJSON' Encoding arity (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a -> U1 a -> Encoding Source #

ToJSON1 f => GToJSON' Value One (Rec1 f) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> Rec1 f a -> Value Source #

ToJSON1 f => GToJSON' Encoding One (Rec1 f) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

(WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON' Value arity (a :*: b) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a0 -> (a :*: b) a0 -> Value Source #

ToJSON a => GToJSON' Value arity (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value arity a0 -> K1 i a a0 -> Value Source #

(EncodeProduct arity a, EncodeProduct arity b) => GToJSON' Encoding arity (a :*: b) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> (a :*: b) a0 -> Encoding Source #

ToJSON a => GToJSON' Encoding arity (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding arity a0 -> K1 i a a0 -> Encoding Source #

(ToJSON1 f, GToJSON' Value One g) => GToJSON' Value One (f :.: g) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Value One a -> (f :.: g) a -> Value Source #

(ToJSON1 f, GToJSON' Encoding One g) => GToJSON' Encoding One (f :.: g) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

gToJSON :: Options -> ToArgs Encoding One a -> (f :.: g) a -> Encoding Source #

v ~ Value => KeyValuePair v (DList Pair) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

pair :: Key -> v -> DList Pair Source #

FromPairs Value (DList Pair) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

type Rep Value Source # 
Instance details

Defined in Data.Aeson.Types.Internal

data Key Source #

Instances

Instances details
Eq Key Source # 
Instance details

Defined in Data.Aeson.Key

Methods

(==) :: Key -> Key -> Bool Source #

(/=) :: Key -> Key -> Bool Source #

Data Key Source # 
Instance details

Defined in Data.Aeson.Key

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Key -> c Key Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Key Source #

toConstr :: Key -> Constr Source #

dataTypeOf :: Key -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Key) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Key) Source #

gmapT :: (forall b. Data b => b -> b) -> Key -> Key Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Key -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Key -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Key -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Key -> m Key Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Key -> m Key Source #

Ord Key Source # 
Instance details

Defined in Data.Aeson.Key

Methods

compare :: Key -> Key -> Ordering Source #

(<) :: Key -> Key -> Bool Source #

(<=) :: Key -> Key -> Bool Source #

(>) :: Key -> Key -> Bool Source #

(>=) :: Key -> Key -> Bool Source #

max :: Key -> Key -> Key Source #

min :: Key -> Key -> Key Source #

Read Key Source # 
Instance details

Defined in Data.Aeson.Key

Show Key Source # 
Instance details

Defined in Data.Aeson.Key

IsString Key Source # 
Instance details

Defined in Data.Aeson.Key

Semigroup Key Source # 
Instance details

Defined in Data.Aeson.Key

Methods

(<>) :: Key -> Key -> Key Source #

sconcat :: NonEmpty Key -> Key Source #

stimes :: Integral b => b -> Key -> Key Source #

Monoid Key Source # 
Instance details

Defined in Data.Aeson.Key

Function Key Source #

Since: 2.0.3.0

Instance details

Defined in Data.Aeson.Key

Methods

function :: (Key -> b) -> Key :-> b Source #

Arbitrary Key Source #

Since: 2.0.3.0

Instance details

Defined in Data.Aeson.Key

CoArbitrary Key Source #

Since: 2.0.3.0

Instance details

Defined in Data.Aeson.Key

Methods

coarbitrary :: Key -> Gen b -> Gen b Source #

NFData Key Source # 
Instance details

Defined in Data.Aeson.Key

Methods

rnf :: Key -> () Source #

Hashable Key Source # 
Instance details

Defined in Data.Aeson.Key

Methods

hashWithSalt :: Int -> Key -> Int Source #

hash :: Key -> Int Source #

FromJSONKey Key Source # 
Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSON Key Source # 
Instance details

Defined in Data.Aeson.Types.FromJSON

ToJSONKey Key Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

KeyValue Pair Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

(.=) :: ToJSON v => Key -> v -> Pair Source #

ToJSON Key Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Lift Key Source # 
Instance details

Defined in Data.Aeson.Key

Methods

lift :: Key -> Q Exp Source #

liftTyped :: Key -> Q (TExp Key) Source #

FunctorWithIndex Key KeyMap Source # 
Instance details

Defined in Data.Aeson.KeyMap

Methods

imap :: (Key -> a -> b) -> KeyMap a -> KeyMap b Source #

FoldableWithIndex Key KeyMap Source # 
Instance details

Defined in Data.Aeson.KeyMap

Methods

ifoldMap :: Monoid m => (Key -> a -> m) -> KeyMap a -> m Source #

ifoldMap' :: Monoid m => (Key -> a -> m) -> KeyMap a -> m Source #

ifoldr :: (Key -> a -> b -> b) -> b -> KeyMap a -> b Source #

ifoldl :: (Key -> b -> a -> b) -> b -> KeyMap a -> b Source #

ifoldr' :: (Key -> a -> b -> b) -> b -> KeyMap a -> b Source #

ifoldl' :: (Key -> b -> a -> b) -> b -> KeyMap a -> b Source #

TraversableWithIndex Key KeyMap Source # 
Instance details

Defined in Data.Aeson.KeyMap

Methods

itraverse :: Applicative f => (Key -> a -> f b) -> KeyMap a -> f (KeyMap b) Source #

SemialignWithIndex Key KeyMap Source # 
Instance details

Defined in Data.Aeson.KeyMap

Methods

ialignWith :: (Key -> These a b -> c) -> KeyMap a -> KeyMap b -> KeyMap c Source #

ZipWithIndex Key KeyMap Source # 
Instance details

Defined in Data.Aeson.KeyMap

Methods

izipWith :: (Key -> a -> b -> c) -> KeyMap a -> KeyMap b -> KeyMap c Source #

FilterableWithIndex Key KeyMap Source # 
Instance details

Defined in Data.Aeson.KeyMap

Methods

imapMaybe :: (Key -> a -> Maybe b) -> KeyMap a -> KeyMap b Source #

ifilter :: (Key -> a -> Bool) -> KeyMap a -> KeyMap a Source #

WitherableWithIndex Key KeyMap Source # 
Instance details

Defined in Data.Aeson.KeyMap

Methods

iwither :: Applicative f => (Key -> a -> f (Maybe b)) -> KeyMap a -> f (KeyMap b) Source #

iwitherM :: Monad m => (Key -> a -> m (Maybe b)) -> KeyMap a -> m (KeyMap b) Source #

ifilterA :: Applicative f => (Key -> a -> f Bool) -> KeyMap a -> f (KeyMap a) Source #

v ~ Value => KeyValuePair v (DList Pair) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

Methods

pair :: Key -> v -> DList Pair Source #

FromPairs Value (DList Pair) Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON

type Array = Vector Value Source #

A JSON "array" (sequence).

emptyArray :: Value Source #

The empty array.

isEmptyArray :: Value -> Bool Source #

Determines if the Value is an empty Array. Note that: isEmptyArray emptyArray.

type Pair = (Key, Value) Source #

A key/value pair for an Object.

type Object = KeyMap Value Source #

A JSON "object" (key/value map).

emptyObject :: Value Source #

The empty object.

Type conversion

data Parser a Source #

A JSON parser. N.B. This might not fit your usual understanding of "parser". Instead you might like to think of Parser as a "parse result", i.e. a parser to which the input has already been applied.

Instances

Instances details
Monad Parser Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(>>=) :: Parser a -> (a -> Parser b) -> Parser b Source #

(>>) :: Parser a -> Parser b -> Parser b Source #

return :: a -> Parser a Source #

Functor Parser Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fmap :: (a -> b) -> Parser a -> Parser b Source #

(<$) :: a -> Parser b -> Parser a Source #

MonadFail Parser Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fail :: String -> Parser a Source #

Applicative Parser Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

pure :: a -> Parser a Source #

(<*>) :: Parser (a -> b) -> Parser a -> Parser b Source #

liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c Source #

(*>) :: Parser a -> Parser b -> Parser b Source #

(<*) :: Parser a -> Parser b -> Parser a Source #

Alternative Parser Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

empty :: Parser a Source #

(<|>) :: Parser a -> Parser a -> Parser a Source #

some :: Parser a -> Parser [a] Source #

many :: Parser a -> Parser [a] Source #

MonadPlus Parser Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

mzero :: Parser a Source #

mplus :: Parser a -> Parser a -> Parser a Source #

Semigroup (Parser a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(<>) :: Parser a -> Parser a -> Parser a Source #

sconcat :: NonEmpty (Parser a) -> Parser a Source #

stimes :: Integral b => b -> Parser a -> Parser a Source #

Monoid (Parser a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

data Result a Source #

The result of running a Parser.

Constructors

Error String 
Success a 

Instances

Instances details
Monad Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(>>=) :: Result a -> (a -> Result b) -> Result b Source #

(>>) :: Result a -> Result b -> Result b Source #

return :: a -> Result a Source #

Functor Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fmap :: (a -> b) -> Result a -> Result b Source #

(<$) :: a -> Result b -> Result a Source #

MonadFail Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fail :: String -> Result a Source #

Applicative Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

pure :: a -> Result a Source #

(<*>) :: Result (a -> b) -> Result a -> Result b Source #

liftA2 :: (a -> b -> c) -> Result a -> Result b -> Result c Source #

(*>) :: Result a -> Result b -> Result b Source #

(<*) :: Result a -> Result b -> Result a Source #

Foldable Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fold :: Monoid m => Result m -> m Source #

foldMap :: Monoid m => (a -> m) -> Result a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Result a -> m Source #

foldr :: (a -> b -> b) -> b -> Result a -> b Source #

foldr' :: (a -> b -> b) -> b -> Result a -> b Source #

foldl :: (b -> a -> b) -> b -> Result a -> b Source #

foldl' :: (b -> a -> b) -> b -> Result a -> b Source #

foldr1 :: (a -> a -> a) -> Result a -> a Source #

foldl1 :: (a -> a -> a) -> Result a -> a Source #

toList :: Result a -> [a] Source #

null :: Result a -> Bool Source #

length :: Result a -> Int Source #

elem :: Eq a => a -> Result a -> Bool Source #

maximum :: Ord a => Result a -> a Source #

minimum :: Ord a => Result a -> a Source #

sum :: Num a => Result a -> a Source #

product :: Num a => Result a -> a Source #

Traversable Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

traverse :: Applicative f => (a -> f b) -> Result a -> f (Result b) Source #

sequenceA :: Applicative f => Result (f a) -> f (Result a) Source #

mapM :: Monad m => (a -> m b) -> Result a -> m (Result b) Source #

sequence :: Monad m => Result (m a) -> m (Result a) Source #

Alternative Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

empty :: Result a Source #

(<|>) :: Result a -> Result a -> Result a Source #

some :: Result a -> Result [a] Source #

many :: Result a -> Result [a] Source #

MonadPlus Result Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

mzero :: Result a Source #

mplus :: Result a -> Result a -> Result a Source #

Eq a => Eq (Result a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(==) :: Result a -> Result a -> Bool Source #

(/=) :: Result a -> Result a -> Bool Source #

Show a => Show (Result a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Semigroup (Result a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(<>) :: Result a -> Result a -> Result a Source #

sconcat :: NonEmpty (Result a) -> Result a Source #

stimes :: Integral b => b -> Result a -> Result a Source #

Monoid (Result a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

NFData a => NFData (Result a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

rnf :: Result a -> () Source #

data IResult a Source #

The internal result of running a Parser.

Constructors

IError JSONPath String 
ISuccess a 

Instances

Instances details
Monad IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(>>=) :: IResult a -> (a -> IResult b) -> IResult b Source #

(>>) :: IResult a -> IResult b -> IResult b Source #

return :: a -> IResult a Source #

Functor IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fmap :: (a -> b) -> IResult a -> IResult b Source #

(<$) :: a -> IResult b -> IResult a Source #

MonadFail IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fail :: String -> IResult a Source #

Applicative IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

pure :: a -> IResult a Source #

(<*>) :: IResult (a -> b) -> IResult a -> IResult b Source #

liftA2 :: (a -> b -> c) -> IResult a -> IResult b -> IResult c Source #

(*>) :: IResult a -> IResult b -> IResult b Source #

(<*) :: IResult a -> IResult b -> IResult a Source #

Foldable IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

fold :: Monoid m => IResult m -> m Source #

foldMap :: Monoid m => (a -> m) -> IResult a -> m Source #

foldMap' :: Monoid m => (a -> m) -> IResult a -> m Source #

foldr :: (a -> b -> b) -> b -> IResult a -> b Source #

foldr' :: (a -> b -> b) -> b -> IResult a -> b Source #

foldl :: (b -> a -> b) -> b -> IResult a -> b Source #

foldl' :: (b -> a -> b) -> b -> IResult a -> b Source #

foldr1 :: (a -> a -> a) -> IResult a -> a Source #

foldl1 :: (a -> a -> a) -> IResult a -> a Source #

toList :: IResult a -> [a] Source #

null :: IResult a -> Bool Source #

length :: IResult a -> Int Source #

elem :: Eq a => a -> IResult a -> Bool Source #

maximum :: Ord a => IResult a -> a Source #

minimum :: Ord a => IResult a -> a Source #

sum :: Num a => IResult a -> a Source #

product :: Num a => IResult a -> a Source #

Traversable IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

traverse :: Applicative f => (a -> f b) -> IResult a -> f (IResult b) Source #

sequenceA :: Applicative f => IResult (f a) -> f (IResult a) Source #

mapM :: Monad m => (a -> m b) -> IResult a -> m (IResult b) Source #

sequence :: Monad m => IResult (m a) -> m (IResult a) Source #

Alternative IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

MonadPlus IResult Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

mzero :: IResult a Source #

mplus :: IResult a -> IResult a -> IResult a Source #

Eq a => Eq (IResult a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(==) :: IResult a -> IResult a -> Bool Source #

(/=) :: IResult a -> IResult a -> Bool Source #

Show a => Show (IResult a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Semigroup (IResult a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

(<>) :: IResult a -> IResult a -> IResult a Source #

sconcat :: NonEmpty (IResult a) -> IResult a Source #

stimes :: Integral b => b -> IResult a -> IResult a Source #

Monoid (IResult a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

NFData a => NFData (IResult a) Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

rnf :: IResult a -> () Source #

data JSONPathElement Source #

Elements of a JSON path used to describe the location of an error.

Constructors

Key Key

JSON path element of a key into an object, "object.key".

Index !Int

JSON path element of an index into an array, "array[index]".

iparse :: (a -> Parser b) -> a -> IResult b Source #

Run a Parser.

parse :: (a -> Parser b) -> a -> Result b Source #

Run a Parser.

parseEither :: (a -> Parser b) -> a -> Either String b Source #

Run a Parser with an Either result type. If the parse fails, the Left payload will contain an error message.

parseMaybe :: (a -> Parser b) -> a -> Maybe b Source #

Run a Parser with a Maybe result type.

parseFail :: String -> Parser a Source #

Raise a parsing failure with some custom message.

modifyFailure :: (String -> String) -> Parser a -> Parser a Source #

If the inner Parser failed, modify the failure message using the provided function. This allows you to create more descriptive error messages. For example:

parseJSON (Object o) = modifyFailure
    ("Parsing of the Foo value failed: " ++)
    (Foo <$> o .: "someField")

Since 0.6.2.0

prependFailure :: String -> Parser a -> Parser a Source #

If the inner Parser failed, prepend the given string to the failure message.

prependFailure s = modifyFailure (s ++)

parserThrowError :: JSONPath -> String -> Parser a Source #

Throw a parser error with an additional path.

Since: 1.2.1.0

parserCatchError :: Parser a -> (JSONPath -> String -> Parser a) -> Parser a Source #

A handler function to handle previous errors and return to normal execution.

Since: 1.2.1.0

formatError :: JSONPath -> String -> String Source #

Annotate an error message with a JSONPath error location.

formatPath :: JSONPath -> String Source #

Format a JSONPath as a String, representing the root object as $.

formatRelativePath :: JSONPath -> String Source #

Format a JSONPath as a String which represents the path relative to some root object.

(<?>) :: Parser a -> JSONPathElement -> Parser a Source #

Add JSON Path context to a parser

When parsing a complex structure, it helps to annotate (sub)parsers with context, so that if an error occurs, you can find its location.

withObject "Person" $ \o ->
  Person
    <$> o .: "name" <?> Key "name"
    <*> o .: "age"  <?> Key "age"

(Standard methods like (.:) already do this.)

With such annotations, if an error occurs, you will get a JSON Path location of that error.

Since 0.10

Constructors and accessors

object :: [Pair] -> Value Source #

Create a Value from a list of name/value Pairs. If duplicate keys arise, later keys and their associated values win.

Generic and TH encoding configuration

data Options Source #

Options that specify how to encode/decode your datatype to/from JSON.

Options can be set using record syntax on defaultOptions with the fields below.

Instances

Instances details
Show Options Source # 
Instance details

Defined in Data.Aeson.Types.Internal

data SumEncoding Source #

Specifies how to encode constructors of a sum datatype.

Constructors

TaggedObject

A constructor will be encoded to an object with a field tagFieldName which specifies the constructor tag (modified by the constructorTagModifier). If the constructor is a record the encoded record fields will be unpacked into this object. So make sure that your record doesn't have a field with the same label as the tagFieldName. Otherwise the tag gets overwritten by the encoded value of that field! If the constructor is not a record the encoded constructor contents will be stored under the contentsFieldName field.

UntaggedValue

Constructor names won't be encoded. Instead only the contents of the constructor will be encoded as if the type had a single constructor. JSON encodings have to be disjoint for decoding to work properly.

When decoding, constructors are tried in the order of definition. If some encodings overlap, the first one defined will succeed.

Note: Nullary constructors are encoded as strings (using constructorTagModifier). Having a nullary constructor alongside a single field constructor that encodes to a string leads to ambiguity.

Note: Only the last error is kept when decoding, so in the case of malformed JSON, only an error for the last constructor will be reported.

ObjectWithSingleField

A constructor will be encoded to an object with a single field named after the constructor tag (modified by the constructorTagModifier) which maps to the encoded contents of the constructor.

TwoElemArray

A constructor will be encoded to a 2-element array where the first element is the tag of the constructor (modified by the constructorTagModifier) and the second element the encoded contents of the constructor.

data JSONKeyOptions Source #

Options for encoding keys with genericFromJSONKey and genericToJSONKey.

defaultTaggedObject :: SumEncoding Source #

Default TaggedObject SumEncoding options:

defaultTaggedObject = TaggedObject
                      { tagFieldName      = "tag"
                      , contentsFieldName = "contents"
                      }

Used for changing CamelCase names into something else.

camelTo :: Char -> String -> String Source #

Deprecated: Use camelTo2 for better results

Converts from CamelCase to another lower case, interspersing the character between all capital letters and their previous entries, except those capital letters that appear together, like API.

For use by Aeson template haskell calls.

camelTo '_' 'CamelCaseAPI' == "camel_case_api"

camelTo2 :: Char -> String -> String Source #

Better version of camelTo. Example where it works better:

camelTo '_' "CamelAPICase" == "camel_apicase"
camelTo2 '_' "CamelAPICase" == "camel_api_case"

Other types

newtype DotNetTime Source #

A newtype wrapper for UTCTime that uses the same non-standard serialization format as Microsoft .NET, whose System.DateTime type is by default serialized to JSON as in the following example:

/Date(1302547608878)/

The number represents milliseconds since the Unix epoch.

Constructors

DotNetTime 

Fields

Instances

Instances details
Eq DotNetTime Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Ord DotNetTime Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Read DotNetTime Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Show DotNetTime Source # 
Instance details

Defined in Data.Aeson.Types.Internal

FormatTime DotNetTime Source # 
Instance details

Defined in Data.Aeson.Types.Internal

Methods

formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> DotNetTime -> String) Source #

FromJSON DotNetTime Source # 
Instance details

Defined in Data.Aeson.Types.FromJSON

ToJSON DotNetTime Source # 
Instance details

Defined in Data.Aeson.Types.ToJSON