tagged-json helps you derive aeson and openapi3 instances with a flat,
explicitly-tagged JSON representation.
It is built around DerivingVia and one exported module: Deriving.TaggedJson.
- Deriving via
GTaggedJSONfor:ToJSONFromJSONToSchemaToKeyMap(helper class used by the generic JSON encoder)
- Flat object encoding (no extra wrapper nesting for constructors/newtypes)
- Explicit sum tags (
tagKey) for unambiguous sum decoding - Configurable field/constructor/datatype name modifiers
- Optional omission of
Nothingfields during encoding - Schema customization via
SchemaDetails
To run the tests, run:
cabal testFormatting:
fourmolu -i .
cabal-fmt -i tagged-json.cabalLinting:
hlint -j .See the runnable example in:
Run the example with:
cabal run tagged-json-example- If a datatype has multiple constructors,
tagKeymust be set. - If two types with the same name co-exist in the same OpenApi schema, their definitions will conflict.