| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.API.JSONToCBOR
Synopsis
- serialiseJSONWithSchema :: API -> TypeName -> Value -> ByteString
- jsonToCBORWithSchema :: API -> TypeName -> Value -> Term
- deserialiseJSONWithSchema :: API -> TypeName -> ByteString -> Value
- postprocessJSON :: API -> TypeName -> Value -> Either ValueError Value
Documentation
serialiseJSONWithSchema :: API -> TypeName -> Value -> ByteString Source #
Serialise a JSON value as a CBOR term in a generic but schema-dependent fashion. This is necessary because the JSON representation carries less information than we need in CBOR (e.g. it lacks a distinction between bytestrings and text).
jsonToCBORWithSchema :: API -> TypeName -> Value -> Term Source #
Convert a JSON value into a CBOR term in a generic but schema-dependent fashion.
deserialiseJSONWithSchema :: API -> TypeName -> ByteString -> Value Source #
When a JSON value has been deserialised from CBOR, the
representation may need some modifications in order to match the
result of toJSON on a Haskell datatype. In particular, Aeson's
representation of Maybe does not round-trip (because Nothing is
encoded as Null and as Just x), so CBOR uses a
different representation (as an empty or 1-element list).toJSON x
postprocessJSON :: API -> TypeName -> Value -> Either ValueError Value Source #