Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- newtype JSON = JSON {
- unJSON :: EncodeConfig -> Builder
- toBuilder :: EncodeConfig -> JSON -> Builder
- encodeWith :: EncodeConfig -> JSON -> ByteString
- encode :: JSON -> ByteString
- newtype EncodeConfig = EncodeConfig {
- escapeHtml :: Bool
- unsafeToJSON :: Builder -> JSON
- bool :: Bool -> JSON
- null :: JSON
- integral :: Integral i => i -> JSON
- double :: Double -> JSON
- float :: Float -> JSON
- text :: Text -> JSON
- lazyText :: Text -> JSON
- utf8 :: ByteString -> JSON
- lazyUtf8 :: ByteString -> JSON
- array' :: Foldable f => (a -> JSON) -> f a -> JSON
- array :: Foldable f => f JSON -> JSON
- object' :: Foldable f => (k -> Text) -> (a -> JSON) -> f (k, a) -> JSON
- object :: Foldable f => f (Text, JSON) -> JSON
- unsafeObject' :: Foldable f => (k -> Text) -> (a -> JSON) -> f (k, a) -> JSON
- unsafeObject :: Foldable f => f (Text, JSON) -> JSON
Documentation
JSON encoding data type
JSON | |
|
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
newtype EncodeConfig Source
>>>
def :: EncodeConfig
EncodeConfig {escapeHtml = False}
EncodeConfig | |
|
unsafeToJSON :: Builder -> JSON Source
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 :: Foldable f => f JSON -> JSON Source
convert to json array
>>>
array [integral 4, bool True]
"[4,true]"