aeson 0.3.2.9 → 0.3.2.10
raw patch · 7 files changed
+34/−14 lines, 7 filesdep ~blaze-textual
Dependency ranges changed: blaze-textual
Files
- Data/Aeson/Encode.hs +5/−2
- Data/Aeson/Parser.hs +2/−1
- Data/Aeson/Types.hs +7/−7
- README.markdown +11/−0
- aeson.cabal +7/−2
- benchmarks/AesonEncode.hs +1/−1
- benchmarks/AesonParse.hs +1/−1
Data/Aeson/Encode.hs view
@@ -8,7 +8,8 @@ -- Stability: experimental -- Portability: portable ----- Efficiently serialize a JSON value as a lazy 'L.ByteString'.+-- Efficiently serialize a JSON value as a lazy 'L.ByteString',+-- encoded as UTF-8. module Data.Aeson.Encode (@@ -69,7 +70,9 @@ fromNumber :: Number -> Builder fromNumber (I i) = integral i-fromNumber (D d) = double d+fromNumber (D d)+ | isNaN d || isInfinite d = "null"+ | otherwise = double d -- | Efficiently serialize a JSON value as a lazy 'L.ByteString'. encode :: ToJSON a => a -> L.ByteString
Data/Aeson/Parser.hs view
@@ -8,7 +8,8 @@ -- Stability: experimental -- Portability: portable ----- Efficiently and correctly parse a JSON string.+-- Efficiently and correctly parse a JSON string. The string must be+-- encoded as UTF-8. module Data.Aeson.Parser (
Data/Aeson/Types.hs view
@@ -393,13 +393,13 @@ {-# INLINE parseJSON #-} instance ToJSON Float where- toJSON = Number . fromRational . toRational+ toJSON = Number . realToFrac {-# INLINE toJSON #-} instance FromJSON Float where- parseJSON (Number n) = case n of- D d -> pure . fromRational . toRational $ d- I i -> pure (fromIntegral i)+ parseJSON (Number n) = pure $ case n of+ D d -> realToFrac d+ I i -> fromIntegral i parseJSON Null = pure (0/0) parseJSON v = typeMismatch "Float" v {-# INLINE parseJSON #-}@@ -409,9 +409,9 @@ {-# INLINE toJSON #-} instance FromJSON (Ratio Integer) where- parseJSON (Number n) = case n of- D d -> pure . toRational $ d- I i -> pure (fromIntegral i)+ parseJSON (Number n) = pure $ case n of+ D d -> toRational d+ I i -> fromIntegral i parseJSON v = typeMismatch "Ratio Integer" v {-# INLINE parseJSON #-}
README.markdown view
@@ -2,6 +2,17 @@ aeson is a fast Haskell library for working with JSON data. +# Important note for users of GHCi and Template Haskell++This package depends on the [blaze-textual+package](http://hackage.haskell.org/package/blaze-textual) , and is+unfortunately subject to crashes if you use GHCi or Template Haskell+in your work.++For complete details, including a workaround, see the writeup in [the+blaze-textual+README](https://github.com/mailrank/blaze-textual#readme).+ # Join in! We are happy to receive bug reports, fixes, documentation enhancements,
aeson.cabal view
@@ -1,5 +1,5 @@ name: aeson-version: 0.3.2.9+version: 0.3.2.10 license: BSD3 license-file: LICENSE category: Text, Web, JSON@@ -17,6 +17,11 @@ A JSON parsing and encoding library optimized for ease of use and high performance. .+ /Note/: if you use GHCi or Template Haskell, please see the+ @README@ file for important details about building this package,+ and other packages that depend on it:+ <https://github.com/mailrank/aeson#readme>+ . Parsing performance on a late 2010 MacBook Pro (2.66GHz Core i7), for mostly-English tweets from Twitter's JSON search API: .@@ -111,7 +116,7 @@ attoparsec >= 0.8.6.1, base == 4.*, blaze-builder >= 0.2.1.4,- blaze-textual,+ blaze-textual >= 0.2.0.2, bytestring, containers, deepseq,
benchmarks/AesonEncode.hs view
@@ -39,6 +39,6 @@ _ -> error $ "failed to read " ++ show arg loop 0 r delta <- flip diffUTCTime start `fmap` getCurrentTime- let rate = fromIntegral count / (fromRational . toRational) delta :: Double+ let rate = fromIntegral count / realToFrac delta :: Double putStrLn $ " " ++ show delta putStrLn $ " " ++ show (round rate) ++ " per second"
benchmarks/AesonParse.hs view
@@ -29,5 +29,5 @@ (good, _) <- loop 0 0 delta <- flip diffUTCTime start `fmap` getCurrentTime putStrLn $ " " ++ show good ++ " good, " ++ show delta- let rate = fromIntegral count / (fromRational . toRational) delta :: Double+ let rate = fromIntegral count / realToFrac delta :: Double putStrLn $ " " ++ show (round rate) ++ " per second"