Safe Haskell | None |
---|---|
Language | Haskell98 |
Documentation
encode :: ToJSON a => a -> ByteString
Efficiently serialize a JSON value as a lazy ByteString
.
decode :: FromJSON a => ByteString -> Maybe a
Efficiently deserialize a JSON value from a lazy ByteString
.
If this fails due to incomplete or invalid input, Nothing
is
returned.
The input must consist solely of a JSON document, with no trailing data except for whitespace. This restriction is necessary to ensure that if data is being lazily read from a file handle, the file handle will be closed in a timely fashion once the document has been parsed.
This function parses immediately, but defers conversion. See
json
for details.
eitherDecode :: FromJSON a => ByteString -> Either String a
Like decode
but returns an error message when decoding fails.