codec-0.1.1: First-class record construction and bidirectional serialization

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Codec

Contents

Synopsis

JSON codecs

type JSONCodec a = ConcreteCodec Value Parser a Source

JSON codec. This is just a ToJSON/FromJSON implementation wrapped up in newtypes. Use def to get a JSONCodec for a ToJSON/FromJSON instance.

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.

entry :: Text -> JSONCodec a -> ObjectCodec a Source

Read/write a given value from/to a given key in the current object, using a given sub-codec. ObjectCodec's IsString instance is equal to entry def.

pair :: ToJSON a => Text -> a -> ObjectBuilder () Source

Produce a key-value pair.

obj :: String -> ObjectCodec a -> JSONCodec a Source

Turn an ObjectCodec into a JSONCodec with an expected name (see withObject).