Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- withText :: String -> (Text -> Parser a) -> Value -> Parser a
- withObject :: String -> (Object -> Parser a) -> Value -> Parser a
- data Parser a
- jsonEitherDecode :: FromJSON a => ByteString -> Either String a
- jsonEncode :: ToJSON a => a -> ByteString
Aeson re-exports
withObject :: String -> (Object -> Parser a) -> Value -> Parser a #
applies withObject
name f valuef
to the Object
when value
is an Object
and fails otherwise.
Error message example
withObject "MyType" f (String "oops") -- Error: "parsing MyType failed, expected Object, but encountered String"
Aeson.Types re-exports
A JSON parser. N.B. This might not fit your usual understanding of
"parser". Instead you might like to think of Parser
as a "parse result",
i.e. a parser to which the input has already been applied.
Aeson functions
jsonEitherDecode :: FromJSON a => ByteString -> Either String a Source #
Function alias for Aeson.eitherDecode
jsonEncode :: ToJSON a => a -> ByteString Source #
Function alias for Aeson.encode