Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class DefaultJsonFormat a where
- aesonJsonFormat :: (ToJSON a, FromJSON a) => JsonFormat e a
- abeJsonFormat :: ToJSON a => Parse e a -> JsonFormat e a
- boolJsonFormat :: JsonFormat e Bool
- charJsonFormat :: JsonFormat e Char
- scientificJsonFormat :: JsonFormat e Scientific
- realFloatToJson :: RealFloat a => a -> Value
- realFloatJsonFormat :: RealFloat a => JsonFormat e a
- integralJsonFormat :: Integral a => JsonFormat e a
- stringJsonFormat :: JsonFormat e String
- textJsonFormat :: JsonFormat e Text
- nullJsonFormat :: JsonFormat e ()
- aesonValueJsonFormat :: JsonFormat e Value
- aesonObjectJsonFormat :: JsonFormat e Object
- aesonArrayJsonFormat :: JsonFormat e Array
Documentation
class DefaultJsonFormat a where Source #
Class for associating a default JSON format with a type.
DO NOT use this as the primary interface. It should only be used for defaulting in contexts where an explicit choice can also be used.
defaultJsonFormat :: JsonFormat e a Source #
Produce the default JsonFormat
for type a
, which must not produce any custom errors.
aesonJsonFormat :: (ToJSON a, FromJSON a) => JsonFormat e a Source #
Produce an explicit JsonFormat
by using the implicit Aeson FromJSON
and ToJSON
instances.
If an aeson-better-errors
parser is available for a
, it's probably better to use abeJsonFormat
to get the enhanced error reporting.
abeJsonFormat :: ToJSON a => Parse e a -> JsonFormat e a Source #
Produce an explicit JsonFormat
by using the implicit Aeson ToJSON
instance and an explicit aeson-better-errors
Parse
.
boolJsonFormat :: JsonFormat e Bool Source #
JsonFormat
for Bool
, mapping to a JSON boolean.
charJsonFormat :: JsonFormat e Char Source #
JsonFormat
for Char
, mapping to a JSON string.
scientificJsonFormat :: JsonFormat e Scientific Source #
JsonFormat
for Scientific
, mapping to a JSON number.
Warning: some JSON parsing libraries do not accept the scientific number notation even though it's part of the JSON standard, and this format
uses scientificBuilder
transitively which encodes very small (and large ( 9,999,999.0) fractional numbers
using scientific notation.
realFloatToJson :: RealFloat a => a -> Value Source #
realFloatJsonFormat :: RealFloat a => JsonFormat e a Source #
Polymorphic JSON format for any type which instances RealFloat
. See warning in documentation for scientificJsonFormat
about scientific notation.
integralJsonFormat :: Integral a => JsonFormat e a Source #
Polymorphic JSON format for any type which instances Integral
.
stringJsonFormat :: JsonFormat e String Source #
JSON format for String
.
textJsonFormat :: JsonFormat e Text Source #
JSON format for Text
.
nullJsonFormat :: JsonFormat e () Source #
JSON format for '()' which maps to JSON as null
.
aesonValueJsonFormat :: JsonFormat e Value Source #
JSON format which does no parsing or encoding.
aesonObjectJsonFormat :: JsonFormat e Object Source #
JSON format for Object
which maps to any object in JSON.
aesonArrayJsonFormat :: JsonFormat e Array Source #
JSON format for Array
which maps to any array in JSON.