| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Text.Blaze.JSON
- data JSON
- newtype EncodeConfig = EncodeConfig {
- escapeHtml :: Bool
- def :: Default a => a
- toBuilder :: EncodeConfig -> JSON -> Builder
- encodeWith :: EncodeConfig -> JSON -> ByteString
- encode :: JSON -> ByteString
- null :: JSON
- bool :: Bool -> JSON
- integral :: Integral i => i -> JSON
- double :: Double -> JSON
- text :: Text -> JSON
- lazyText :: Text -> JSON
- utf8 :: ByteString -> JSON
- lazyUtf8 :: ByteString -> JSON
- array :: Foldable f => f JSON -> JSON
- object :: Foldable f => f (Text, JSON) -> JSON
- module Text.Blaze.JSON.Class
Documentation
JSON encoding data type
configuration
newtype EncodeConfig Source
>>>def :: EncodeConfigEncodeConfig {escapeHtml = False}
Constructors
| EncodeConfig | |
Fields
| |
Instances
convert
toBuilder :: EncodeConfig -> JSON -> Builder Source
convert JSON to bytestring Builder.
encodeWith :: EncodeConfig -> JSON -> ByteString Source
encode JSON using given config
encode :: JSON -> ByteString Source
encode = encodeWith def
constructors
null
bool
number
string
lazyText :: Text -> JSON Source
json text value from LazyText
>>>print $ lazyText "bar\0""\"bar\\u0000\""
utf8 :: ByteString -> JSON Source
utf8 encoded bytestring to JSON. since v0.2.0.
>>>utf8 $ T.encodeUtf8 "\29483""\"\29483\""
lazyUtf8 :: ByteString -> JSON Source
utf8 encoded lazy bytestring to JSON. since v0.2.0.
>>>lazyUtf8 $ TL.encodeUtf8 "\29356""\"\29356\""
array
array :: Foldable f => f JSON -> JSON Source
convert to json array
>>>array [integral 4, bool True]"[4,true]"
object
object :: Foldable f => f (Text, JSON) -> JSON Source
O(nlogn) convert to object
prior value is prevailed.
You could use unsafeObject when could ensure unique key.
>>>object [("foo", integral 12), ("bar", bool True), ("foo", text "ignored")]"{\"foo\":12,\"bar\":true}"
reexports
module Text.Blaze.JSON.Class