Safe Haskell | None |
---|
- defaultLayoutJson :: (Yesod master, ToJSON a) => GWidget sub master () -> a -> GHandler sub master RepHtmlJson
- jsonToRepJson :: ToJSON a => a -> GHandler sub master RepJson
- parseJsonBody :: FromJSON a => GHandler sub master (Result a)
- parseJsonBody_ :: FromJSON a => GHandler sub master a
- data Value
- object :: ToJSON a => [(Text, a)] -> Value
- array :: ToJSON a => [a] -> Value
- (.=) :: ToJSON a => Text -> a -> Pair
- jsonOrRedirect :: (Yesod master, ToJSON a) => Route master -> a -> GHandler sub master RepJson
- acceptsJson :: Yesod master => GHandler sub master Bool
Convert from a JSON value
:: (Yesod master, ToJSON a) | |
=> GWidget sub master () | HTML |
-> a | JSON |
-> GHandler sub master RepHtmlJson |
Provide both an HTML and JSON representation for a piece of
data, using the default layout for the HTML output
(defaultLayout
).
Since: 0.3.0
jsonToRepJson :: ToJSON a => a -> GHandler sub master RepJsonSource
Convert to a JSON value
parseJsonBody :: FromJSON a => GHandler sub master (Result a)Source
parseJsonBody_ :: FromJSON a => GHandler sub master aSource
Same as parseJsonBody
, but return an invalid args response on a parse
error.
Produce JSON values
data Value
A JSON value represented as a Haskell value.
Convenience functions
:: (Yesod master, ToJSON a) | |
=> Route master | Redirect target |
-> a | Data to send via JSON |
-> GHandler sub master RepJson |
jsonOrRedirect simplifies the scenario where a POST handler sends a different response based on Accept headers:
- 200 with JSON data if the client prefers
application/json
(e.g. AJAX, seeacceptsJSON
). - 3xx otherwise, following the PRG pattern.
acceptsJson :: Yesod master => GHandler sub master BoolSource
Returns True
if the client prefers application/json
as
indicated by the Accept
HTTP header.