The generic-aeson package

[ Tags: bsd3, data, library ] [ Propose Tags ]

Derivation of Aeson instances using GHC generics.

[Skip to Readme]


Versions 0.1,,,, 0.1.1,,,,,,,,,,,
Change log
Dependencies aeson (>=0.6 && <1.3), attoparsec (>=0.11 && <0.14), base (>=4.4 && <4.11), generic-deriving (>=1.6 && <1.12), ghc-prim, mtl (>=2.0 && <2.3), tagged (>=0.2 && <0.9), text (>=0.11 && <1.3), unordered-containers (==0.2.*), vector (>=0.10 && <0.13) [details]
License BSD3
Author Silk
Category Data
Source repository head: git clone
Uploaded Sun Apr 23 11:02:53 UTC 2017 by AdamBergmark
Updated Thu Jul 27 16:44:53 UTC 2017 by AdamBergmark to revision 1
Distributions LTSHaskell:, NixOS:, Stackage:, Tumbleweed:
Downloads 5339 total (36 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-04-23 [all 1 reports]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees

Readme for generic-aeson-

[back to package description]


Build Status

The structure of the generated JSON is meant to be close to idiomatic JSON. This means:

  • Enumerations (data types containing constructors without fields) are converted to JSON strings.

  • Record fields become JSON keys.

  • Data types with one unlabeled field convert to just that field.

  • Data types with multiple unlabeled fields become arrays.

  • Multiple constructors are represented by keys.

  • Maybe values are either an absent key, or the value.

  • Leading and trailing underscores are removed from constructor names and record fields

See tests/Main.hs in json-schema for more examples.

How does generic-aeson compare to the TH/Generics already present in aeson?

generic-aeson contains more special cases for creating more concise and idiomatic json. If you're working with the JSON representation directly generic-aeson should feel more natural.

Will the generated format ever change?

Changing the format would incur a breaking change to every API that uses generic-aeson so we must keep it intact.

If we find a bug where the fix changes the format we need to create a new package or version the generation code.


json-schema has generic derivation of schemas that match the generic-aeson format.