json-enumerator 0.0.0 → 0.0.1
raw patch · 2 files changed
+69/−1 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.JSON.ToJson: class ToJson a
+ Text.JSON.ToJson: instance (ToJson a, ToJson b) => ToJson (a, b)
+ Text.JSON.ToJson: instance (ToJson a, ToJson b, ToJson c) => ToJson (a, b, c)
+ Text.JSON.ToJson: instance (ToJson a, ToJson b, ToJson c, ToJson d) => ToJson (a, b, c, d)
+ Text.JSON.ToJson: instance ToJson ()
+ Text.JSON.ToJson: instance ToJson Bool
+ Text.JSON.ToJson: instance ToJson ByteString
+ Text.JSON.ToJson: instance ToJson Char
+ Text.JSON.ToJson: instance ToJson Double
+ Text.JSON.ToJson: instance ToJson Float
+ Text.JSON.ToJson: instance ToJson Int
+ Text.JSON.ToJson: instance ToJson Int32
+ Text.JSON.ToJson: instance ToJson Int64
+ Text.JSON.ToJson: instance ToJson Text
+ Text.JSON.ToJson: instance ToJson Value
+ Text.JSON.ToJson: instance ToJson a => ToJson [a]
+ Text.JSON.ToJson: toJson :: ToJson a => a -> Value
+ Text.JSON.ToJson: toJsons :: ToJson a => [a] -> Value
Files
- Text/JSON/ToJson.hs +67/−0
- json-enumerator.cabal +2/−1
+ Text/JSON/ToJson.hs view
@@ -0,0 +1,67 @@+module Text.JSON.ToJson (ToJson(..)) where++import qualified Data.JSON.Types as J+import Data.Int (Int32)+import qualified Data.ByteString as S+import qualified Data.ByteString.Lazy as LBS++import Data.Text.Encoding.Error (lenientDecode)++import qualified Data.Text as TS+import qualified Data.Text.Encoding as TSE++import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.Encoding as TLE++import Data.Int (Int64)++class ToJson a where+ toJson :: a -> J.Value++ toJsons :: [a] -> J.Value+ toJsons = J.ValueArray . map toJson++instance ToJson a => ToJson [a] where+ toJson = toJsons++instance ToJson () where+ toJson _ = J.ValueArray []++instance (ToJson a, ToJson b) => ToJson (a,b) where+ toJson (a,b) = J.ValueArray [ toJson a, toJson b ]++instance (ToJson a, ToJson b, ToJson c) => ToJson (a,b,c) where+ toJson (a,b,c) = J.ValueArray [ toJson a, toJson b, toJson c ]++instance (ToJson a, ToJson b, ToJson c, ToJson d) => ToJson (a,b,c,d) where+ toJson (a,b,c,d) = J.ValueArray [toJson a, toJson b, toJson c, toJson d]++instance ToJson J.Value where+ toJson = id++instance ToJson Bool where+ toJson = J.ValueAtom . J.AtomBoolean++instance ToJson Char where+ toJson c = J.ValueAtom $ J.AtomText $ TL.pack (c:[])+ toJsons = J.ValueAtom . J.AtomText . TL.pack++instance (ToJson S.ByteString) where+ toJson = J.ValueAtom . J.AtomText . TL.fromChunks . return+ . TSE.decodeUtf8With lenientDecode+instance (ToJson LBS.ByteString) where+ toJson = J.ValueAtom . J.AtomText . TLE.decodeUtf8With lenientDecode+instance ToJson TS.Text where+ toJson = J.ValueAtom . J.AtomText . TL.fromChunks . return+instance ToJson TL.Text where+ toJson = J.ValueAtom . J.AtomText+instance (ToJson Int32) where+ toJson = J.ValueAtom . J.AtomNumber . toRational+instance (ToJson Int64) where+ toJson = J.ValueAtom . J.AtomNumber . toRational+instance (ToJson Int) where+ toJson = J.ValueAtom . J.AtomNumber . toRational+instance (ToJson Float) where+ toJson = J.ValueAtom . J.AtomNumber . toRational+instance (ToJson Double) where+ toJson = J.ValueAtom . J.AtomNumber . toRational
json-enumerator.cabal view
@@ -1,5 +1,5 @@ name: json-enumerator-version: 0.0.0+version: 0.0.1 license: BSD3 license-file: LICENSE author: Michael Snoyman <michaels@suite-sol.com>@@ -24,6 +24,7 @@ , blaze-builder-enumerator >= 0.2 && < 0.3 , transformers >= 0.2 && < 0.3 exposed-modules: Text.JSON.Enumerator+ Text.JSON.ToJson ghc-options: -Wall source-repository head