| Copyright | (C) 2015 Oleg Grenrus |
|---|---|
| License | BSD3 |
| Maintainer | Oleg Grenrus <oleg.grenrus@iki.fi> |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Aeson.Compat
Contents
Description
Compatibility notices
decodeetc. work as inaeson >=0.9- but it is generalised to work in any
MonadThrow(that is extra) .:?works as inaeson ||=0.11.:!works as inaeson ||=0.11and as.:?did inaeson ==0.10.*- Orphan instances
FromJSONDayandFromJSONLocalTimeforaeson <0.10 Encodingrelated functionality is not added. It's present only withaeson >=0.10
- decode :: (FromJSON a, MonadThrow m) => ByteString -> m a
- decode' :: (FromJSON a, MonadThrow m) => ByteString -> m a
- newtype AesonException = AesonException String
- eitherDecode :: FromJSON a => ByteString -> Either String a
- eitherDecode' :: FromJSON a => ByteString -> Either String a
- encode :: ToJSON a => a -> ByteString
- decodeStrict :: (FromJSON a, MonadThrow m) => ByteString -> m a
- decodeStrict' :: (FromJSON a, MonadThrow m) => ByteString -> m a
- eitherDecodeStrict :: FromJSON a => ByteString -> Either String a
- eitherDecodeStrict' :: FromJSON a => ByteString -> Either String a
- data Value :: *
- type Encoding = Encoding' Value
- fromEncoding :: Encoding' tag -> Builder
- type Array = Vector Value
- type Object = HashMap Text Value
- newtype DotNetTime :: * = DotNetTime {}
- class FromJSON a where
- data Result a :: * -> *
- fromJSON :: FromJSON a => Value -> Result a
- class ToJSON a where
- class KeyValue kv where
- class GFromJSON arity f
- class GToJSON arity f
- class GToEncoding arity f
- genericToJSON :: (Generic a, GToJSON Zero (Rep a)) => Options -> a -> Value
- genericToEncoding :: (Generic a, GToEncoding Zero (Rep a)) => Options -> a -> Encoding
- genericParseJSON :: (Generic a, GFromJSON Zero (Rep a)) => Options -> Value -> Parser a
- defaultOptions :: Options
- withObject :: String -> (Object -> Parser a) -> Value -> Parser a
- withText :: String -> (Text -> Parser a) -> Value -> Parser a
- withArray :: String -> (Array -> Parser a) -> Value -> Parser a
- withNumber :: String -> (Number -> Parser a) -> Value -> Parser a
- withScientific :: String -> (Scientific -> Parser a) -> Value -> Parser a
- withBool :: String -> (Bool -> Parser a) -> Value -> Parser a
- data Series :: *
- pairs :: Series -> Encoding
- foldable :: (Foldable t, ToJSON a) => t a -> Encoding
- (.:) :: FromJSON a => Object -> Text -> Parser a
- (.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a)
- (.:!) :: FromJSON a => Object -> Text -> Parser (Maybe a)
- (.!=) :: Parser (Maybe a) -> a -> Parser a
- object :: [Pair] -> Value
- json :: Parser Value
- json' :: Parser Value
- value :: Parser Value
- value' :: Parser Value
- data Parser a :: * -> *
Encoding and decoding
Direct encoding
decode :: (FromJSON a, MonadThrow m) => ByteString -> m a Source #
Like original decode but in arbitrary MonadThrow.
Parse a top-level JSON value, i.e. also strings, numbers etc.
decode' :: (FromJSON a, MonadThrow m) => ByteString -> m a Source #
Like original decode' but in arbitrary MonadThrow.
newtype AesonException Source #
Exception thrown by decode - family of functions in this module.
Constructors
| AesonException String |
Instances
eitherDecode :: FromJSON a => ByteString -> Either String a #
eitherDecode' :: FromJSON a => ByteString -> Either String a #
encode :: ToJSON a => a -> ByteString #
Variants for strict bytestrings
decodeStrict :: (FromJSON a, MonadThrow m) => ByteString -> m a Source #
Like original decodeStrict but in arbitrary MonadThrow.
decodeStrict' :: (FromJSON a, MonadThrow m) => ByteString -> m a Source #
Like original decodeStrict' but in arbitrary MonadThrow.
eitherDecodeStrict :: FromJSON a => ByteString -> Either String a #
eitherDecodeStrict' :: FromJSON a => ByteString -> Either String a #
Core JSON types
fromEncoding :: Encoding' tag -> Builder #
Convenience types
newtype DotNetTime :: * #
Constructors
| DotNetTime | |
Fields | |
Type conversion
Instances
Instances
Minimal complete definition
Generic JSON classes and options
Minimal complete definition
gParseJSON
Instances
| GFromJSON arity U1 | |
| GFromJSON One Par1 | |
| FromJSON1 f => GFromJSON One (Rec1 f) | |
| ConsFromJSON arity a => GFromJSON arity (C1 c a) | |
| FromJSON a => GFromJSON arity (K1 i a) | |
| (AllNullary ((:+:) a b) allNullary, ParseSum * arity ((:+:) a b) allNullary) => GFromJSON arity ((:+:) a b) | |
| (FromProduct arity a, FromProduct arity b, ProductSize a, ProductSize b) => GFromJSON arity ((:*:) a b) | |
| (FromJSON1 f, GFromJSON One g) => GFromJSON One ((:.:) f g) | |
| GFromJSON arity a => GFromJSON arity (M1 i c a) | |
Minimal complete definition
gToJSON
Instances
| GToJSON arity U1 | |
| GToJSON One Par1 | |
| ToJSON1 f => GToJSON One (Rec1 f) | |
| ConsToJSON arity a => GToJSON arity (C1 c a) | |
| ToJSON a => GToJSON arity (K1 i a) | |
| (AllNullary ((:+:) a b) allNullary, SumToJSON * arity ((:+:) a b) allNullary) => GToJSON arity ((:+:) a b) | |
| (WriteProduct arity a, WriteProduct arity b, ProductSize a, ProductSize b) => GToJSON arity ((:*:) a b) | |
| (ToJSON1 f, GToJSON One g) => GToJSON One ((:.:) f g) | |
| GToJSON arity a => GToJSON arity (M1 i c a) | |
class GToEncoding arity f #
Minimal complete definition
gToEncoding
Instances
| GToEncoding arity U1 | |
| GToEncoding One Par1 | |
| ToJSON1 f => GToEncoding One (Rec1 f) | |
| ConsToEncoding arity a => GToEncoding arity (C1 c a) | |
| ToJSON a => GToEncoding arity (K1 i a) | |
| (AllNullary ((:+:) a b) allNullary, SumToEncoding * arity ((:+:) a b) allNullary) => GToEncoding arity ((:+:) a b) | |
| (EncodeProduct arity a, EncodeProduct arity b) => GToEncoding arity ((:*:) a b) | |
| (ToJSON1 f, GToEncoding One g) => GToEncoding One ((:.:) f g) | |
| GToEncoding arity a => GToEncoding arity (M1 i c a) | |
genericToEncoding :: (Generic a, GToEncoding Zero (Rep a)) => Options -> a -> Encoding #
defaultOptions :: Options #
Inspecting Values
ValuesConstructors and accessors
(.:?) :: FromJSON a => Object -> Text -> Parser (Maybe a) Source #
Retrieve the value associated with the given key of an Object.
The result is Nothing if the key is not present, or empty if
the value cannot be converted to the desired type.
This accessor is most useful if the key and value can be absent
from an object without affecting its validity. If the key and
value are mandatory, use .: instead.
This operator is consistent in aeson >=0.7 && <0.11