| 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.10.:!works as.:?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 :: *
- data Encoding :: *
- fromEncoding :: Encoding -> 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 f where
- class GToJSON f where
- class GToEncoding f where
- genericToJSON :: (Generic a, GToJSON (Rep a)) => Options -> a -> Value
- genericToEncoding :: (Generic a, GToEncoding (Rep a)) => Options -> a -> Encoding
- genericParseJSON :: (Generic a, GFromJSON (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 -> Builder #
Convenience types
Type conversion
Minimal complete definition
Generic JSON classes and options
Minimal complete definition
Methods
gParseJSON :: Options -> Value -> Parser (f a) #
Minimal complete definition
class GToEncoding f where #
Minimal complete definition
Methods
gToEncoding :: Options -> f a -> Encoding #
genericToEncoding :: (Generic a, GToEncoding (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