-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Data structure agnostic JSON serialization
--
-- Most json packages define a data structure that corresponds to json
-- values. To serialize other values to a json string, then that value
-- must be marshalled into the json data structure.
--
-- This library avoids this marshalling step, and is thus potentially
-- more efficient when serializing arbitrary data structures.
-- Unfortunately json-builder cannot yet read or process json data, and
-- it's not clear to me yet how pull a similar kind of trick to avoid
-- unnecessary data structures when parsing json data into arbitrary data
-- types.
@package json-builder
@version 0.0
-- | Data structure agnostic JSON serialization
module Data.Json.Builder
-- | The Key typeclass represents types that are rendered into json
-- strings. They are special because only strings can appear as field
-- names of a json objects.
class Value a => Key a
escape :: Key a => a -> Escaped
-- | The Value typeclass represents types that can be rendered into
-- valid json syntax.
class Value a
toBuilder :: Value a => a -> Builder
-- | The Object type represents a builder that constructs syntax for
-- a json object. It has a singleton constructor row, and an
-- instance of monoid, so that arbitrary objects can be constructed. 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.
data Object
-- | The row constructs a json object consisting of exactly one
-- field. These objects can be concatinated using mappend.
row :: (Key k, Value a) => k -> a -> Object
-- | The Array type represents a builder that constructs syntax for
-- a json array. It has a singleton constructor element and an
-- instance of monoid, so that arbitrary arrays can be constructed.
data Array
-- | The element function constructs a json array consisting of
-- exactly one value. These arrays can be concatinated using
-- mappend.
element :: Value a => a -> Array
-- | The Escaped type is a special Builder value that represents a
-- UTF-8 encoded string with all necessary characters json-escaped. These
-- builders must not render the opening or closing quotes, which are
-- instead rendered by toBuilder. This is so that Json strings can
-- be efficiently constructed from multiple Haskell strings without
-- actually concatinating the Haskell strings (which might require some
-- kind of conversion in addition to concatination.)
newtype Escaped
Escaped :: Builder -> Escaped
instance [overlap ok] Monoid Escaped
instance [overlap ok] (Key k, Value a) => Value (Map k a)
instance [overlap ok] Value a => Value [a]
instance [overlap ok] Value [Char]
instance [overlap ok] Key [Char]
instance [overlap ok] Value Text
instance [overlap ok] Key Text
instance [overlap ok] Value Text
instance [overlap ok] Key Text
instance [overlap ok] Value ByteString
instance [overlap ok] Key ByteString
instance [overlap ok] Value ByteString
instance [overlap ok] Key ByteString
instance [overlap ok] Value Bool
instance [overlap ok] Value Float
instance [overlap ok] Value Double
instance [overlap ok] Value Word64
instance [overlap ok] Value Word32
instance [overlap ok] Value Word16
instance [overlap ok] Value Word8
instance [overlap ok] Value Word
instance [overlap ok] Value Integer
instance [overlap ok] Value Int64
instance [overlap ok] Value Int32
instance [overlap ok] Value Int16
instance [overlap ok] Value Int8
instance [overlap ok] Value Int
instance [overlap ok] Value ()
instance [overlap ok] Monoid Array
instance [overlap ok] Value Array
instance [overlap ok] Monoid Object
instance [overlap ok] Value Object
instance [overlap ok] Value Escaped
instance [overlap ok] Key Escaped