aeson-extra-0.4.1.3: Extra goodies for aeson

Copyright(C) 2015-2016 Oleg Grenrus
LicenseBSD3
MaintainerOleg Grenrus <oleg.grenrus@iki.fi>
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Extra

Contents

Description

More or less useful newtypes for writing FromJSON & ToJSON instances

Synopsis

Strict encoding

encodeStrict :: ToJSON a => a -> ByteString Source #

Like encode, but produces strict ByteString.

Since: 0.2.3.0

Generic maps

newtype M a Source #

A wrapper type to parse arbitrary maps

λ > decode "{\"1\": 1, \"2\": 2}" :: Maybe (M (H.HashMap Int Int))
Just (M {getMap = fromList [(1,1),(2,2)]})

Constructors

M 

Fields

Instances
Functor M Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

fmap :: (a -> b) -> M a -> M b #

(<$) :: a -> M b -> M a #

Foldable M Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

fold :: Monoid m => M m -> m #

foldMap :: Monoid m => (a -> m) -> M a -> m #

foldr :: (a -> b -> b) -> b -> M a -> b #

foldr' :: (a -> b -> b) -> b -> M a -> b #

foldl :: (b -> a -> b) -> b -> M a -> b #

foldl' :: (b -> a -> b) -> b -> M a -> b #

foldr1 :: (a -> a -> a) -> M a -> a #

foldl1 :: (a -> a -> a) -> M a -> a #

toList :: M a -> [a] #

null :: M a -> Bool #

length :: M a -> Int #

elem :: Eq a => a -> M a -> Bool #

maximum :: Ord a => M a -> a #

minimum :: Ord a => M a -> a #

sum :: Num a => M a -> a #

product :: Num a => M a -> a #

Traversable M Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

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

sequenceA :: Applicative f => M (f a) -> f (M a) #

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

sequence :: Monad m => M (m a) -> m (M a) #

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

Defined in Data.Aeson.Extra.Map

Methods

(==) :: M a -> M a -> Bool #

(/=) :: M a -> M a -> Bool #

Ord a => Ord (M a) Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

compare :: M a -> M a -> Ordering #

(<) :: M a -> M a -> Bool #

(<=) :: M a -> M a -> Bool #

(>) :: M a -> M a -> Bool #

(>=) :: M a -> M a -> Bool #

max :: M a -> M a -> M a #

min :: M a -> M a -> M a #

Read a => Read (M a) Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

readsPrec :: Int -> ReadS (M a) #

readList :: ReadS [M a] #

readPrec :: ReadPrec (M a) #

readListPrec :: ReadPrec [M a] #

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

Defined in Data.Aeson.Extra.Map

Methods

showsPrec :: Int -> M a -> ShowS #

show :: M a -> String #

showList :: [M a] -> ShowS #

ToJSONMap m k v => ToJSON (M m) Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

toJSON :: M m -> Value #

toEncoding :: M m -> Encoding #

toJSONList :: [M m] -> Value #

toEncodingList :: [M m] -> Encoding #

FromJSONMap m k v => FromJSON (M m) Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

parseJSON :: Value -> Parser (M m) #

parseJSONList :: Value -> Parser [M m] #

class FromJSONKey a where Source #

Instances
FromJSONKey Int Source # 
Instance details

Defined in Data.Aeson.Extra.Map

FromJSONKey Integer Source # 
Instance details

Defined in Data.Aeson.Extra.Map

FromJSONKey String Source # 
Instance details

Defined in Data.Aeson.Extra.Map

FromJSONKey Text Source # 
Instance details

Defined in Data.Aeson.Extra.Map

FromJSONKey Text Source # 
Instance details

Defined in Data.Aeson.Extra.Map

class FromJSONMap m k v | m -> k v where Source #

Instances
(Eq k, Hashable k, FromJSONKey k, FromJSON v) => FromJSONMap (HashMap k v) k v Source # 
Instance details

Defined in Data.Aeson.Extra.Map

(Ord k, FromJSONKey k, FromJSON v) => FromJSONMap (Map k v) k v Source # 
Instance details

Defined in Data.Aeson.Extra.Map

class ToJSONKey a where Source #

Methods

toJSONKey :: a -> Text Source #

Instances
ToJSONKey Int Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

toJSONKey :: Int -> Text Source #

ToJSONKey Integer Source # 
Instance details

Defined in Data.Aeson.Extra.Map

ToJSONKey String Source # 
Instance details

Defined in Data.Aeson.Extra.Map

ToJSONKey Text Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

toJSONKey :: Text -> Text Source #

ToJSONKey Text Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Methods

toJSONKey :: Text -> Text0 Source #

class ToJSONMap m k v | m -> k v where Source #

Instances
(ToJSONKey k, ToJSON v) => ToJSONMap (HashMap k v) k v Source # 
Instance details

Defined in Data.Aeson.Extra.Map

(ToJSONKey k, ToJSON v) => ToJSONMap (Map k v) k v Source # 
Instance details

Defined in Data.Aeson.Extra.Map

Symbol tag

data SymTag (s :: Symbol) Source #

Singleton string encoded and decoded as ifself.

λ> encode (SymTag :: SymTag "foobar")
"\"foobar\""
decode "\"foobar\"" :: Maybe (SymTag "foobar")
Just SymTag
decode "\"foobar\"" :: Maybe (SymTag "barfoo")
Nothing

Available with: base >=4.7

Constructors

SymTag 
Instances
Bounded (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

Methods

minBound :: SymTag s #

maxBound :: SymTag s #

Enum (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

Methods

succ :: SymTag s -> SymTag s #

pred :: SymTag s -> SymTag s #

toEnum :: Int -> SymTag s #

fromEnum :: SymTag s -> Int #

enumFrom :: SymTag s -> [SymTag s] #

enumFromThen :: SymTag s -> SymTag s -> [SymTag s] #

enumFromTo :: SymTag s -> SymTag s -> [SymTag s] #

enumFromThenTo :: SymTag s -> SymTag s -> SymTag s -> [SymTag s] #

Eq (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

Methods

(==) :: SymTag s -> SymTag s -> Bool #

(/=) :: SymTag s -> SymTag s -> Bool #

Ord (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

Methods

compare :: SymTag s -> SymTag s -> Ordering #

(<) :: SymTag s -> SymTag s -> Bool #

(<=) :: SymTag s -> SymTag s -> Bool #

(>) :: SymTag s -> SymTag s -> Bool #

(>=) :: SymTag s -> SymTag s -> Bool #

max :: SymTag s -> SymTag s -> SymTag s #

min :: SymTag s -> SymTag s -> SymTag s #

Read (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

Show (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

Methods

showsPrec :: Int -> SymTag s -> ShowS #

show :: SymTag s -> String #

showList :: [SymTag s] -> ShowS #

KnownSymbol s => ToJSON (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

KnownSymbol s => FromJSON (SymTag s) Source # 
Instance details

Defined in Data.Aeson.Extra.SymTag

NFData (SymTag s) Source #

Since: 0.4.1.0

Instance details

Defined in Data.Aeson.Extra.SymTag

Methods

rnf :: SymTag s -> () #

Singleton object

newtype SingObject (s :: Symbol) a Source #

Singleton value object

λ > decode "{\"value\": 42 }" :: Maybe (SingObject "value" Int)
Just (SingObject 42)
λ > encode (SingObject 42 :: SingObject "value" Int)
"{\"value\":42}"

Available with: base >=4.7

Constructors

SingObject a 
Instances
Functor (SingObject s) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

fmap :: (a -> b) -> SingObject s a -> SingObject s b #

(<$) :: a -> SingObject s b -> SingObject s a #

Foldable (SingObject s) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

fold :: Monoid m => SingObject s m -> m #

foldMap :: Monoid m => (a -> m) -> SingObject s a -> m #

foldr :: (a -> b -> b) -> b -> SingObject s a -> b #

foldr' :: (a -> b -> b) -> b -> SingObject s a -> b #

foldl :: (b -> a -> b) -> b -> SingObject s a -> b #

foldl' :: (b -> a -> b) -> b -> SingObject s a -> b #

foldr1 :: (a -> a -> a) -> SingObject s a -> a #

foldl1 :: (a -> a -> a) -> SingObject s a -> a #

toList :: SingObject s a -> [a] #

null :: SingObject s a -> Bool #

length :: SingObject s a -> Int #

elem :: Eq a => a -> SingObject s a -> Bool #

maximum :: Ord a => SingObject s a -> a #

minimum :: Ord a => SingObject s a -> a #

sum :: Num a => SingObject s a -> a #

product :: Num a => SingObject s a -> a #

Traversable (SingObject s) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

traverse :: Applicative f => (a -> f b) -> SingObject s a -> f (SingObject s b) #

sequenceA :: Applicative f => SingObject s (f a) -> f (SingObject s a) #

mapM :: Monad m => (a -> m b) -> SingObject s a -> m (SingObject s b) #

sequence :: Monad m => SingObject s (m a) -> m (SingObject s a) #

KnownSymbol s => ToJSON1 (SingObject s) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> SingObject s a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [SingObject s a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> SingObject s a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [SingObject s a] -> Encoding #

KnownSymbol s => FromJSON1 (SingObject s) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (SingObject s a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [SingObject s a] #

Eq a => Eq (SingObject s a) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

(==) :: SingObject s a -> SingObject s a -> Bool #

(/=) :: SingObject s a -> SingObject s a -> Bool #

Ord a => Ord (SingObject s a) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

compare :: SingObject s a -> SingObject s a -> Ordering #

(<) :: SingObject s a -> SingObject s a -> Bool #

(<=) :: SingObject s a -> SingObject s a -> Bool #

(>) :: SingObject s a -> SingObject s a -> Bool #

(>=) :: SingObject s a -> SingObject s a -> Bool #

max :: SingObject s a -> SingObject s a -> SingObject s a #

min :: SingObject s a -> SingObject s a -> SingObject s a #

Read a => Read (SingObject s a) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Show a => Show (SingObject s a) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

showsPrec :: Int -> SingObject s a -> ShowS #

show :: SingObject s a -> String #

showList :: [SingObject s a] -> ShowS #

(KnownSymbol s, ToJSON a) => ToJSON (SingObject s a) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

(KnownSymbol s, FromJSON a) => FromJSON (SingObject s a) Source # 
Instance details

Defined in Data.Aeson.Extra.SingObject

NFData a => NFData (SingObject s a) Source #

Since: 0.4.1.0

Instance details

Defined in Data.Aeson.Extra.SingObject

Methods

rnf :: SingObject s a -> () #

CollapsedList

newtype CollapsedList f a Source #

Collapsed list, singleton is represented as the value itself in JSON encoding.

λ > decode "null" :: Maybe (CollapsedList [Int] Int)
Just (CollapsedList [])
λ > decode "42" :: Maybe (CollapsedList [Int] Int)
Just (CollapsedList [42])
λ > decode "[1, 2, 3]" :: Maybe (CollapsedList [Int] Int)
Just (CollapsedList [1,2,3])
λ > encode (CollapsedList ([] :: [Int]))
"null"
λ > encode (CollapsedList ([42] :: [Int]))
"42"
λ > encode (CollapsedList ([1, 2, 3] :: [Int]))
"[1,2,3]"

Documentation rely on f Alternative instance behaving like lists'.

Constructors

CollapsedList (f a) 
Instances
Functor f => Functor (CollapsedList f) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Methods

fmap :: (a -> b) -> CollapsedList f a -> CollapsedList f b #

(<$) :: a -> CollapsedList f b -> CollapsedList f a #

Foldable f => Foldable (CollapsedList f) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Methods

fold :: Monoid m => CollapsedList f m -> m #

foldMap :: Monoid m => (a -> m) -> CollapsedList f a -> m #

foldr :: (a -> b -> b) -> b -> CollapsedList f a -> b #

foldr' :: (a -> b -> b) -> b -> CollapsedList f a -> b #

foldl :: (b -> a -> b) -> b -> CollapsedList f a -> b #

foldl' :: (b -> a -> b) -> b -> CollapsedList f a -> b #

foldr1 :: (a -> a -> a) -> CollapsedList f a -> a #

foldl1 :: (a -> a -> a) -> CollapsedList f a -> a #

toList :: CollapsedList f a -> [a] #

null :: CollapsedList f a -> Bool #

length :: CollapsedList f a -> Int #

elem :: Eq a => a -> CollapsedList f a -> Bool #

maximum :: Ord a => CollapsedList f a -> a #

minimum :: Ord a => CollapsedList f a -> a #

sum :: Num a => CollapsedList f a -> a #

product :: Num a => CollapsedList f a -> a #

Traversable f => Traversable (CollapsedList f) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Methods

traverse :: Applicative f0 => (a -> f0 b) -> CollapsedList f a -> f0 (CollapsedList f b) #

sequenceA :: Applicative f0 => CollapsedList f (f0 a) -> f0 (CollapsedList f a) #

mapM :: Monad m => (a -> m b) -> CollapsedList f a -> m (CollapsedList f b) #

sequence :: Monad m => CollapsedList f (m a) -> m (CollapsedList f a) #

(ToJSON1 f, Foldable f) => ToJSON1 (CollapsedList f) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Methods

liftToJSON :: (a -> Value) -> ([a] -> Value) -> CollapsedList f a -> Value #

liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [CollapsedList f a] -> Value #

liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> CollapsedList f a -> Encoding #

liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [CollapsedList f a] -> Encoding #

(FromJSON1 f, Alternative f) => FromJSON1 (CollapsedList f) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Methods

liftParseJSON :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (CollapsedList f a) #

liftParseJSONList :: (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser [CollapsedList f a] #

Eq (f a) => Eq (CollapsedList f a) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Methods

(==) :: CollapsedList f a -> CollapsedList f a -> Bool #

(/=) :: CollapsedList f a -> CollapsedList f a -> Bool #

Ord (f a) => Ord (CollapsedList f a) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Read (f a) => Read (CollapsedList f a) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

Show (f a) => Show (CollapsedList f a) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

(ToJSON1 f, Foldable f, ToJSON a) => ToJSON (CollapsedList f a) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

(FromJSON1 f, Alternative f, FromJSON a) => FromJSON (CollapsedList f a) Source # 
Instance details

Defined in Data.Aeson.Extra.CollapsedList

parseCollapsedList :: (FromJSON a, FromJSON1 f, Alternative f) => Object -> Text -> Parser (f a) Source #

Parses possibly collapsed array value from the object's field.

λ > newtype V = V [Int] deriving (Show)
λ > instance FromJSON V where parseJSON = withObject "V" $ \obj -> V <$> parseCollapsedList obj "value"
λ > decode "{}" :: Maybe V
Just (V [])
λ > decode "{\"value\": null}" :: Maybe V
Just (V [])
λ > decode "{\"value\": 42}" :: Maybe V
Just (V [42])
λ > decode "{\"value\": [1, 2, 3, 4]}" :: Maybe V
Just (V [1,2,3,4])

UTCTime

newtype U Source #

A type to parse UTCTime

FromJSON instance accepts for example:

2015-09-07T08:16:40.807Z
2015-09-07 11:16:40.807 +03:00

Latter format is accepted by aeson staring from version 0.10.0.0.

See https://github.com/bos/aeson/blob/4667ef1029a373cf4510f7deca147c357c6d8947/Data/Aeson/Parser/Time.hs#L150

Since: aeson-extra-0.2.2.0

Constructors

U 

Fields

Instances
Eq U Source # 
Instance details

Defined in Data.Aeson.Extra.Time

Methods

(==) :: U -> U -> Bool #

(/=) :: U -> U -> Bool #

Ord U Source # 
Instance details

Defined in Data.Aeson.Extra.Time

Methods

compare :: U -> U -> Ordering #

(<) :: U -> U -> Bool #

(<=) :: U -> U -> Bool #

(>) :: U -> U -> Bool #

(>=) :: U -> U -> Bool #

max :: U -> U -> U #

min :: U -> U -> U #

Read U Source # 
Instance details

Defined in Data.Aeson.Extra.Time

Show U Source # 
Instance details

Defined in Data.Aeson.Extra.Time

Methods

showsPrec :: Int -> U -> ShowS #

show :: U -> String #

showList :: [U] -> ShowS #

ToJSON U Source # 
Instance details

Defined in Data.Aeson.Extra.Time

FromJSON U Source # 
Instance details

Defined in Data.Aeson.Extra.Time

newtype Z Source #

A type to parse ZonedTime

Since: aeson-extra-0.2.2.0

Constructors

Z 

Fields

Instances
Read Z Source # 
Instance details

Defined in Data.Aeson.Extra.Time

Show Z Source # 
Instance details

Defined in Data.Aeson.Extra.Time

Methods

showsPrec :: Int -> Z -> ShowS #

show :: Z -> String #

showList :: [Z] -> ShowS #

ToJSON Z Source # 
Instance details

Defined in Data.Aeson.Extra.Time

FromJSON Z Source # 
Instance details

Defined in Data.Aeson.Extra.Time

Algebra

data ValueF a Source #

An algebra of Value

Since: aeson-extra-0.3.1.0

Instances
Functor ValueF Source # 
Instance details

Defined in Data.Aeson.Extra.Recursive

Methods

fmap :: (a -> b) -> ValueF a -> ValueF b #

(<$) :: a -> ValueF b -> ValueF a #

Foldable ValueF Source # 
Instance details

Defined in Data.Aeson.Extra.Recursive

Methods

fold :: Monoid m => ValueF m -> m #

foldMap :: Monoid m => (a -> m) -> ValueF a -> m #

foldr :: (a -> b -> b) -> b -> ValueF a -> b #

foldr' :: (a -> b -> b) -> b -> ValueF a -> b #

foldl :: (b -> a -> b) -> b -> ValueF a -> b #

foldl' :: (b -> a -> b) -> b -> ValueF a -> b #

foldr1 :: (a -> a -> a) -> ValueF a -> a #

foldl1 :: (a -> a -> a) -> ValueF a -> a #

toList :: ValueF a -> [a] #

null :: ValueF a -> Bool #

length :: ValueF a -> Int #

elem :: Eq a => a -> ValueF a -> Bool #

maximum :: Ord a => ValueF a -> a #

minimum :: Ord a => ValueF a -> a #

sum :: Num a => ValueF a -> a #

product :: Num a => ValueF a -> a #

Traversable ValueF Source # 
Instance details

Defined in Data.Aeson.Extra.Recursive

Methods

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

sequenceA :: Applicative f => ValueF (f a) -> f (ValueF a) #

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

sequence :: Monad m => ValueF (m a) -> m (ValueF a) #

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

Defined in Data.Aeson.Extra.Recursive

Methods

(==) :: ValueF a -> ValueF a -> Bool #

(/=) :: ValueF a -> ValueF a -> Bool #

Data a => Data (ValueF a) Source # 
Instance details

Defined in Data.Aeson.Extra.Recursive

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ValueF a -> c (ValueF a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ValueF a) #

toConstr :: ValueF a -> Constr #

dataTypeOf :: ValueF a -> DataType #

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

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

gmapT :: (forall b. Data b => b -> b) -> ValueF a -> ValueF a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ValueF a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ValueF a -> r #

gmapQ :: (forall d. Data d => d -> u) -> ValueF a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ValueF a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ValueF a -> m (ValueF a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ValueF a -> m (ValueF a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ValueF a -> m (ValueF a) #

Read a => Read (ValueF a) Source # 
Instance details

Defined in Data.Aeson.Extra.Recursive

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

Defined in Data.Aeson.Extra.Recursive

Methods

showsPrec :: Int -> ValueF a -> ShowS #

show :: ValueF a -> String #

showList :: [ValueF a] -> ShowS #

type ObjectF a = HashMap Text a Source #

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

Since: aeson-extra-0.3.1.0

type ArrayF a = Vector a Source #

A JSON "array" (sequence).

Since: aeson-extra-0.3.1.0

Merge

merge :: (forall a. (a -> a -> a) -> ValueF a -> ValueF a -> ValueF a) -> Value -> Value -> Value Source #

Generic merge.

For example see lodashMerge.

Since: aeson-extra-0.3.1.0

lodashMerge :: Value -> Value -> Value Source #

Example of using merge. see https://lodash.com/docs#merge:

Note: not tested against JavaScript lodash, so may disagree in the results.

Since: 0.4.1.0

Stream

streamDecode :: forall a. FromJSON a => ByteString -> ([a], Maybe String) Source #

Lazyly parse ByteString with top-level JSON array.

Note: inspecting result's second field will force the list!

let ~(values, err) = streamDecode bs
traverse_ processValue values
maybe (pure ()) printError err

Since: 0.3.2.0

Template Haskell

mkValue :: String -> Q Exp Source #

Create a Value from string representation.

This is useful in tests.

Since: aeson-extra-0.3.1.0

mkValue' :: String -> Q Exp Source #

Like mkValue, but replace single quotes with double quotes before.

> $(mkValue' "{'a': 2 }")
Object (fromList [("a",Number 2.0)])

Since: aeson-extra-0.3.1.0

Re-exports