Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data JSONCodec a = JSONCodec {
- parseJSONCodec :: Value -> Parser a
- toJSONCodec :: a -> Value
- toEncodingCodec :: a -> Encoding
- defJSON :: (FromJSON a, ToJSON a) => JSONCodec a
- type ObjectParser = ReaderT Object Parser
- type ObjectBuilder = Writer (Series, Endo [Pair])
- type ObjectCodec a = Codec ObjectParser ObjectBuilder a
- field :: (FromJSON a, ToJSON a) => Text -> ObjectCodec a
- field' :: Text -> JSONCodec a -> ObjectCodec a
- asObject :: String -> ObjectCodec a -> JSONCodec a
- type ArrayParser = StateT [Value] Parser
- type ArrayBuilder = Writer (Series, [Value])
- type ArrayCodec a = Codec ArrayParser ArrayBuilder a
- element :: (FromJSON a, ToJSON a) => ArrayCodec a
- element' :: JSONCodec a -> ArrayCodec a
- asArray :: String -> ArrayCodec a -> JSONCodec a
- arrayOf :: (FromJSON b, ToJSON b) => (a -> [b]) -> ([b] -> a) -> JSONCodec a
- arrayOf' :: (a -> [b]) -> ([b] -> a) -> JSONCodec b -> JSONCodec a
Documentation
JSONCodec | |
|
JSON object codecs
type ObjectCodec a = Codec ObjectParser ObjectBuilder a Source #
A codec that parses values out of a given Object
, and produces
key-value pairs into a new one.
field :: (FromJSON a, ToJSON a) => Text -> ObjectCodec a Source #
Store/retrieve a value in a given JSON field, with the default JSON serialization.
field' :: Text -> JSONCodec a -> ObjectCodec a Source #
Store/retrieve a value in a given JSON field, with a given JSONCodec.
asObject :: String -> ObjectCodec a -> JSONCodec a Source #
Turn an ObjectCodec
into a JSONCodec
with an expected name (see withObject
).
JSON array codecs
type ArrayCodec a = Codec ArrayParser ArrayBuilder a Source #
A codec that serializes data to a sequence of JSON array elements.
element :: (FromJSON a, ToJSON a) => ArrayCodec a Source #
Expect/append an array element, using the default serialization.
element' :: JSONCodec a -> ArrayCodec a Source #
Expect/append an array element, using a given JSONCodec
.
asArray :: String -> ArrayCodec a -> JSONCodec a Source #
A codec that parses values out of a given Array
, and produces
key-value pairs into a new one.