json-alt: Union 'alternative' or Either that has untagged JSON encoding.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Parsing JSON with Aeson often requires decoding fields that have more than one Haskell type.

So we have:

data a :|: b = AltLeft a
             | AltRight b

printIt = print . (fromJSON :: ByteString -> Int :|: Bool)
main = do
  printIt "1"    -- AltLeft 1
  printIt "true" -- AltRight True
  printIt "null" -- errors!

To generate types for larger JSON documents, you might use json-autotype.

This is separate package so that users do not have to keep json-autotype as runtime dependency.

See https://github.com/mgajda/json-autotype


[Skip to Readme]

Properties

Versions 1.0.0, 1.0.0
Change log changelog.md
Dependencies aeson (>=1.2.1 && <1.5), base (>=4.3 && <5) [details]
License BSD-3-Clause
Copyright Copyright by Migamake '2014-'2018
Author Michal J. Gajda
Maintainer simons@cryp.to, mjgajda@gmail.com
Category Data, Tools
Home page https://github.com/mgajda/json-autotype.git#readme
Bug tracker https://github.com/mgajda/json-autotype.git/issues
Source repo head: git clone https://github.com/mgajda/json-autotype.git
Uploaded by MichalGajda at 2020-04-19T17:28:28Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for json-alt-1.0.0

[back to package description]

json-alt

Runtime module for json-autotype that allows easy parsing of JSON values that have more than a single Haskell type.