Safe Haskell | Safe-Infered |
---|
- (!:) :: FromJSON a => Object -> Text -> WD a
- parseJSON' :: FromJSON a => ByteString -> WD a
- fromJSON' :: FromJSON a => Value -> WD a
- single :: ToJSON a => Text -> a -> Value
- pair :: (ToJSON a, ToJSON b) => (Text, Text) -> (a, b) -> Value
- triple :: (ToJSON a, ToJSON b, ToJSON c) => (Text, Text, Text) -> (a, b, c) -> Value
- parsePair :: (FromJSON a, FromJSON b) => String -> String -> String -> Value -> WD (a, b)
- parseTriple :: (FromJSON a, FromJSON b, FromJSON c) => String -> String -> String -> String -> Value -> WD (a, b, c)
- apResultToWD :: FromJSON a => Result Value -> WD a
- aesonResultToWD :: Result a -> WD a
Access a JSON object key
(!:) :: FromJSON a => Object -> Text -> WD aSource
This operator is a wrapper over Aeson's .:
operator.
Conversion from JSON within WD
Apostrophes are used to disambiguate these functions from their Data.Aeson counterparts.
parseJSON' :: FromJSON a => ByteString -> WD aSource
Parse a lazy ByteString
as a top-level JSON Value
, then convert it to an
instance of FromJSON
..
Tuple functions
Convenience functions for working with tuples.
JSON object constructors
single :: ToJSON a => Text -> a -> ValueSource
Construct a singleton JSON object
from a key and value.
pair :: (ToJSON a, ToJSON b) => (Text, Text) -> (a, b) -> ValueSource
Construct a 2-element JSON object
from a pair of keys and a pair of
values.
triple :: (ToJSON a, ToJSON b, ToJSON c) => (Text, Text, Text) -> (a, b, c) -> ValueSource
Construct a 3-element JSON object
from a triple of keys and a triple of
values.
Extracting JSON objects into tuples
parsePair :: (FromJSON a, FromJSON b) => String -> String -> String -> Value -> WD (a, b)Source
Parse a JSON Object
as a pair. The first two string arguments specify the
keys to extract from the object. The fourth string is the name of the
calling function, for better error reporting.
parseTriple :: (FromJSON a, FromJSON b, FromJSON c) => String -> String -> String -> String -> Value -> WD (a, b, c)Source
Parse a JSON Object as a triple. The first three string arguments specify the keys to extract from the object. The fourth string is the name of the calling function, for better error reporting.
Conversion from parser results to WD
These functions are used to implement the other functions in this module, and could be used to implement other JSON convenience functions
aesonResultToWD :: Result a -> WD aSource
Convert an Aeson parser result to WD
.