Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- buildObject :: (Object -> Object) -> Value
- optionalField :: ToJSON a => Key -> Maybe a -> Object -> Object
- requiredField :: ToJSON a => Key -> a -> Object -> Object
- stripPrefix :: String -> String -> String
Documentation
buildObject :: (Object -> Object) -> Value Source #
Build a JSON object omitting optional keys if a corresponding value is Nothing
.
Example:
buildObject
$ requiredField "field1"
builds this JSON object:
a
. requiredField "field2" c
. optionalField "field3" (Just "hello")
. optionalField "field4" Nothing
{
"field1":
omitting optional a
,
"field2": c
,
"field3": "hello"
}
field4
.
optionalField :: ToJSON a => Key -> Maybe a -> Object -> Object Source #
requiredField :: ToJSON a => Key -> a -> Object -> Object Source #