packages feed

blaze-json 0.1.0 → 0.2.0

raw patch · 3 files changed

+28/−14 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.Blaze.JSON: lazyUtf8 :: ByteString -> JSON
+ Text.Blaze.JSON: utf8 :: ByteString -> JSON
+ Text.Blaze.JSON.Internal: lazyUtf8 :: ByteString -> JSON
+ Text.Blaze.JSON.Internal: utf8 :: ByteString -> JSON

Files

blaze-json.cabal view
@@ -1,5 +1,5 @@ name:                blaze-json-version:             0.1.0+version:             0.2.0 synopsis:            tiny library for encoding json license:             MIT license-file:        LICENSE
src/Text/Blaze/JSON.hs view
@@ -17,7 +17,7 @@       -- ** number     , integral, double       -- ** string-    , text, lazyText+    , text, lazyText, utf8, lazyUtf8       -- ** array     , array       -- ** object
src/Text/Blaze/JSON/Internal.hs view
@@ -13,6 +13,8 @@     , double, float     , text     , lazyText+    , utf8+    , lazyUtf8     , array', array     , object', object     , unsafeObject', unsafeObject@@ -24,9 +26,7 @@ #define COMPATIBILITY 1 #endif -#if COMPATIBILITY import qualified Data.ByteString as S-#endif import qualified Data.ByteString.Lazy as L  import qualified Data.ByteString.Builder as B@@ -173,6 +173,28 @@         BP.char8 BP.>*< BP.char8 BP.>*< BP.word16HexFixed {-# INLINABLE escapeAscii #-} +appendWord8 :: EncodeConfig -> Word8 -> B.Builder -> B.Builder+appendWord8 cfg = \w b -> BP.primBounded (escapeAscii $ escapeHtml cfg) w <> b+{-# INLINE appendWord8 #-}++-- | utf8 encoded bytestring to JSON. since v0.2.0.+--+-- >>> utf8 $ T.encodeUtf8 "\29483"+-- "\"\29483\""+utf8 :: S.ByteString -> JSON+utf8 t = JSON $ \cfg -> surround "\"" "\"" $+    S.foldr (appendWord8 cfg) mempty t+{-# INLINABLE utf8 #-}++-- | utf8 encoded lazy bytestring to JSON. since v0.2.0.+--+-- >>> lazyUtf8 $ TL.encodeUtf8 "\29356"+-- "\"\29356\""+lazyUtf8 :: L.ByteString -> JSON+lazyUtf8 t = JSON $ \cfg -> surround "\"" "\"" $+    L.foldr (appendWord8 cfg) mempty t+{-# INLINABLE lazyUtf8 #-}+ -- | json text value from Text -- -- >>> print $ text "foo\n"@@ -188,16 +210,8 @@ {-# INLINABLE lazyText #-}  #if COMPATIBILITY--appendWord8 :: EncodeConfig -> Word8 -> B.Builder -> B.Builder-appendWord8 cfg = \w b -> BP.primBounded (escapeAscii $ escapeHtml cfg) w <> b-{-# INLINE appendWord8 #-}--text t = JSON $ \cfg -> surround "\"" "\"" $-    S.foldr (appendWord8 cfg) mempty $ T.encodeUtf8 t--lazyText t = JSON $ \cfg -> surround "\"" "\"" $-    L.foldr (appendWord8 cfg) mempty $ TL.encodeUtf8 t+text = utf8 . T.encodeUtf8+lazyText = lazyUtf8 . TL.encodeUtf8 #else  encodeString :: (BP.BoundedPrim Word8 -> a -> B.Builder) -> Bool -> a -> B.Builder