- data JSValue
- class JSON a where
- parseJSON :: ByteString -> Either String JSValue
- readJSON :: ByteString -> Maybe JSValue
- showJSON :: JSValue -> ByteString
- showJSON' :: JSValue -> ByteString
- lookup :: JSON a => ByteString -> JSValue -> Maybe a
- getField :: JSON a => ByteString -> JSValue -> Maybe a
- findWithDefault :: JSON a => a -> ByteString -> JSValue -> a
- lookupDeep :: JSON a => [ByteString] -> JSValue -> Maybe a
- getFields :: JSON a => [ByteString] -> JSValue -> Maybe a
- findDeepWithDefault :: JSON a => a -> [ByteString] -> JSValue -> a
- updateField :: JSON a => ByteString -> a -> JSValue -> JSValue
Class and Data-Types for JSON Value
Data types for JSON value.
Type Class for the value that can be converted from/into JSValue
.
Parsing & Printing
showJSON :: JSValue -> ByteStringSource
Print JSValue
as JSON source (not pretty).
The output string will be in UTF8 (provided the JSValue was constructed with UTF8 strings).
showJSON' :: JSValue -> ByteStringSource
Same as showJSON
, but escape Unicode Charactors.
Manipulating Objects
lookup :: JSON a => ByteString -> JSValue -> Maybe aSource
Get the value for field in Object and decode it.
findWithDefault :: JSON a => a -> ByteString -> JSValue -> aSource
lookup
with default value.
lookupDeep :: JSON a => [ByteString] -> JSValue -> Maybe aSource
Same as lookup
but it can process nested Object. ex:
lookupDeep ["user", "name"] (JSObject [("user", JSObject [("name", JSString "hoge")])]) == Just "hoge"
getFields :: JSON a => [ByteString] -> JSValue -> Maybe aSource
DEPRECATED: Alias of lookupDeep
findDeepWithDefault :: JSON a => a -> [ByteString] -> JSValue -> aSource
getFields
with default value.
updateField :: JSON a => ByteString -> a -> JSValue -> JSValueSource
Update or Insert the value for field in Object.