Description
Union 'alternative' or Either that has untagged JSON encoding.
Description
Parsing JSON with Aeson often requires decoding fields that have more than one Haskell type.
So we have: ``` data a :|: b = AltLeft a | AltLeft 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.
README.md
json-alt
Runtime module for json-autotype
that allows easy parsing of JSON values that have more than a single Haskell type.