Maintainer | Leon P Smith <leon@melding-monads.com> |
---|
Internal bits. You can break this library's abstraction and emit invalid Json syntax the constructors provided in this module.
Documentation
The Value
typeclass represents types that can be rendered
into valid json syntax.
Value Bool | renders as |
Value Double | |
Value Float | |
Value Int | |
Value Int8 | |
Value Int16 | |
Value Int32 | |
Value Int64 | |
Value Integer | |
Value Word | |
Value Word8 | |
Value Word16 | |
Value Word32 | |
Value Word64 | |
Value () | renders as |
Value Text | |
Value Text | |
Value ByteString | |
Value ByteString | |
Value Array | |
Value Object | |
Value Escaped | |
Value Json | |
Value [Char] | |
Value a => Value [a] | renders as an |
(JsString k, Value a) => Value (Map k a) | renders as an |
(JsString k, Value a) => Value (HashMap k a) | renders as an |
The Json
type represents valid json syntax. It cannot be directly
analyzed, however it can be rendered into a ByteString
and used to
as a component of an array or an object to build a bigger json value.
class Value a => JsString a whereSource
The String
typeclass represents types that render into json string
syntax. They are special because only strings can appear as field names
of json objects.
The Escaped
type represents json string syntax. The purpose of this
type is so that json strings can be efficiently constructed from multiple
Haskell strings without superfluous conversions or concatinations.
Internally, it is just a Builder
value which must produce a UTF-8 encoded
bytestring with backslashes, quotes, and control characters appropriately
escaped. It also must not render the opening or closing quote, which
are instead rendered by toJson
.
The Object
type represents syntax for a json object. It has a singleton
constructor row
, and an instance of Monoid
, so that mempty
represents the
empty object and mappend
concatinates two objects. Arbitrary objects can
be constructed using these operators.
Note that duplicate field names will appear in the output, so it is up to the user of this interface to avoid duplicate field names.