Switch to aeson
This commit is contained in:
parent
3bedd2bf75
commit
56d22c4fe2
@ -18,14 +18,15 @@ import Yesod.Content
|
|||||||
)
|
)
|
||||||
import Yesod.Core (defaultLayout, Yesod)
|
import Yesod.Core (defaultLayout, Yesod)
|
||||||
import Yesod.Widget (GWidget)
|
import Yesod.Widget (GWidget)
|
||||||
import qualified Data.JSON.Types as J
|
import qualified Data.Aeson as J
|
||||||
import qualified Text.JSON.Enumerator as J
|
import Data.Aeson.Encode (fromValue)
|
||||||
import Data.Text.Lazy (pack)
|
import Data.Text (pack)
|
||||||
import Control.Arrow (first)
|
import Control.Arrow (first)
|
||||||
import Data.Map (fromList)
|
import Data.Map (fromList)
|
||||||
|
import qualified Data.Vector as V
|
||||||
|
|
||||||
instance ToContent J.Value where
|
instance ToContent J.Value where
|
||||||
toContent = flip ContentBuilder Nothing . J.renderValue
|
toContent = flip ContentBuilder Nothing . fromValue
|
||||||
|
|
||||||
-- | Provide both an HTML and JSON representation for a piece of data, using
|
-- | Provide both an HTML and JSON representation for a piece of data, using
|
||||||
-- the default layout for the HTML output ('defaultLayout').
|
-- the default layout for the HTML output ('defaultLayout').
|
||||||
@ -44,10 +45,10 @@ jsonToRepJson = return . RepJson . toContent
|
|||||||
type Json = J.Value
|
type Json = J.Value
|
||||||
|
|
||||||
jsonScalar :: String -> Json
|
jsonScalar :: String -> Json
|
||||||
jsonScalar = J.ValueAtom . J.AtomText . pack
|
jsonScalar = J.String . pack
|
||||||
|
|
||||||
jsonList :: [Json] -> Json
|
jsonList :: [Json] -> Json
|
||||||
jsonList = J.ValueArray
|
jsonList = J.Array . V.fromList
|
||||||
|
|
||||||
jsonMap :: [(String, Json)] -> Json
|
jsonMap :: [(String, Json)] -> Json
|
||||||
jsonMap = J.ValueObject . fromList . map (first pack)
|
jsonMap = J.Object . fromList . map (first pack)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-json
|
name: yesod-json
|
||||||
version: 0.0.0.1
|
version: 0.1.0
|
||||||
license: BSD3
|
license: BSD3
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
@ -14,10 +14,10 @@ homepage: http://docs.yesodweb.com/
|
|||||||
library
|
library
|
||||||
build-depends: base >= 4 && < 5
|
build-depends: base >= 4 && < 5
|
||||||
, yesod-core >= 0.7 && < 0.8
|
, yesod-core >= 0.7 && < 0.8
|
||||||
, json-enumerator >= 0.0 && < 0.1
|
, aeson >= 0.3.1.1 && < 0.4
|
||||||
, json-types >= 0.1 && < 0.2
|
|
||||||
, containers >= 0.2 && < 0.5
|
|
||||||
, text >= 0.8 && < 0.12
|
, text >= 0.8 && < 0.12
|
||||||
|
, vector
|
||||||
|
, containers
|
||||||
exposed-modules: Yesod.Json
|
exposed-modules: Yesod.Json
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user