From 56d22c4fe22cf773f5c13d4076b046aed82a394d Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Tue, 15 Mar 2011 23:32:10 +0200 Subject: [PATCH] Switch to aeson --- Yesod/Json.hs | 15 ++++++++------- yesod-json.cabal | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Yesod/Json.hs b/Yesod/Json.hs index 4619bdec..f4752c50 100644 --- a/Yesod/Json.hs +++ b/Yesod/Json.hs @@ -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) diff --git a/yesod-json.cabal b/yesod-json.cabal index d4c46142..4056493a 100644 --- a/yesod-json.cabal +++ b/yesod-json.cabal @@ -1,5 +1,5 @@ name: yesod-json -version: 0.0.0.1 +version: 0.1.0 license: BSD3 license-file: LICENSE author: Michael Snoyman @@ -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