Switch to aeson

This commit is contained in:
Michael Snoyman 2011-03-15 23:32:10 +02:00
parent 3bedd2bf75
commit 56d22c4fe2
2 changed files with 12 additions and 11 deletions

View File

@ -18,14 +18,15 @@ import Yesod.Content
)
import Yesod.Core (defaultLayout, Yesod)
import Yesod.Widget (GWidget)
import qualified Data.JSON.Types as J
import qualified Text.JSON.Enumerator as J
import Data.Text.Lazy (pack)
import qualified Data.Aeson as J
import Data.Aeson.Encode (fromValue)
import Data.Text (pack)
import Control.Arrow (first)
import Data.Map (fromList)
import qualified Data.Vector as V
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
-- the default layout for the HTML output ('defaultLayout').
@ -44,10 +45,10 @@ jsonToRepJson = return . RepJson . toContent
type Json = J.Value
jsonScalar :: String -> Json
jsonScalar = J.ValueAtom . J.AtomText . pack
jsonScalar = J.String . pack
jsonList :: [Json] -> Json
jsonList = J.ValueArray
jsonList = J.Array . V.fromList
jsonMap :: [(String, Json)] -> Json
jsonMap = J.ValueObject . fromList . map (first pack)
jsonMap = J.Object . fromList . map (first pack)

View File

@ -1,5 +1,5 @@
name: yesod-json
version: 0.0.0.1
version: 0.1.0
license: BSD3
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
@ -14,10 +14,10 @@ homepage: http://docs.yesodweb.com/
library
build-depends: base >= 4 && < 5
, yesod-core >= 0.7 && < 0.8
, json-enumerator >= 0.0 && < 0.1
, json-types >= 0.1 && < 0.2
, containers >= 0.2 && < 0.5
, aeson >= 0.3.1.1 && < 0.4
, text >= 0.8 && < 0.12
, vector
, containers
exposed-modules: Yesod.Json
ghc-options: -Wall