Add 'parseJsonBody' to Yesod.Json.
This commit is contained in:
parent
3e6235a8ac
commit
9da7d0a1fd
@ -5,6 +5,8 @@ module Yesod.Json
|
||||
( -- * Convert from a JSON value
|
||||
defaultLayoutJson
|
||||
, jsonToRepJson
|
||||
-- * Convert to a JSON value
|
||||
, parseJsonBody
|
||||
-- * Compatibility wrapper for old API
|
||||
, Json
|
||||
, jsonScalar
|
||||
@ -22,8 +24,10 @@ import Yesod.Widget (GWidget)
|
||||
import qualified Data.Aeson as J
|
||||
import qualified Data.Aeson.Encode as JE
|
||||
import Data.Aeson.Encode (fromValue)
|
||||
import Data.Attoparsec.Enumerator (iterParser)
|
||||
import Data.Text (pack)
|
||||
import Control.Arrow (first)
|
||||
import Control.Monad.Trans.Class (lift)
|
||||
#if MIN_VERSION_aeson(0, 4, 0)
|
||||
import Data.HashMap.Strict (fromList)
|
||||
#else
|
||||
@ -62,6 +66,13 @@ defaultLayoutJson w json = do
|
||||
jsonToRepJson :: J.Value -> GHandler sub master RepJson
|
||||
jsonToRepJson = return . RepJson . toContent
|
||||
|
||||
-- | Parse the request body as a JSON value.
|
||||
--
|
||||
-- /Since: 0.2.3/
|
||||
parseJsonBody :: GHandler sub master J.Value
|
||||
parseJsonBody = lift $ iterParser J.json'
|
||||
|
||||
|
||||
type Json = J.Value
|
||||
|
||||
jsonScalar :: String -> Json
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-json
|
||||
version: 0.2.2.3
|
||||
version: 0.2.3
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -13,15 +13,17 @@ homepage: http://www.yesodweb.com/
|
||||
description: Generate content for Yesod using the aeson package.
|
||||
|
||||
library
|
||||
build-depends: base >= 4 && < 5
|
||||
, yesod-core >= 0.9 && < 0.10
|
||||
, aeson >= 0.3
|
||||
, text >= 0.8 && < 0.12
|
||||
, shakespeare-js >= 0.10 && < 0.11
|
||||
, vector >= 0.9
|
||||
, containers >= 0.2 && < 0.5
|
||||
build-depends: base >= 4 && < 5
|
||||
, yesod-core >= 0.9 && < 0.10
|
||||
, aeson >= 0.3
|
||||
, text >= 0.8 && < 0.12
|
||||
, shakespeare-js >= 0.10 && < 0.11
|
||||
, vector >= 0.9
|
||||
, containers >= 0.2 && < 0.5
|
||||
, unordered-containers
|
||||
, blaze-builder
|
||||
, attoparsec-enumerator >= 0.3 && < 0.4
|
||||
, transformers >= 0.2.2 && < 0.3
|
||||
exposed-modules: Yesod.Json
|
||||
ghc-options: -Wall
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user