@@ -84,9 +84,13 @@ import Data.Text.Encoding (encodeUtf8, decodeUtf8With)
84import Data.Text.Encoding.Error (lenientDecode)
84import Data.Text.Encoding.Error (lenientDecode)
85import qualified Data.HashMap.Strict as M
85import qualified Data.HashMap.Strict as M
86import Data.Typeable
86import Data.Typeable
87−import Data.Attoparsec.ByteString (parseOnly)
88−import Data.Aeson.Parser (value)
89import qualified Data.HashSet as HashSet
87import qualified Data.HashSet as HashSet
89+#if MIN_VERSION_aeson(0, 7, 0)
90+import Data.Scientific (fromFloatDigits)
92+import Data.Attoparsec.Number
91encode :: ToJSON a => a -> ByteString
95encode :: ToJSON a => a -> ByteString
92encode obj = unsafePerformIO $
96encode obj = unsafePerformIO $
@@ -210,7 +214,13 @@ textToValue _ _ t
210 | t `elem` ["null", "Null", "NULL", "~", ""] = Null
214 | t `elem` ["null", "Null", "NULL", "~", ""] = Null
211 | any (t `isLike`) ["y", "yes", "on", "true"] = Bool True
215 | any (t `isLike`) ["y", "yes", "on", "true"] = Bool True
212 | any (t `isLike`) ["n", "no", "off", "false"] = Bool False
216 | any (t `isLike`) ["n", "no", "off", "false"] = Bool False
213− | Right (Number n) <- parseOnly value (encodeUtf8 t) = Number n
217+#if MIN_VERSION_aeson(0, 7, 0)
218+ | Right (x, "") <- signed decimal t = Number $ fromIntegral (x :: Integer)
219+ | Right (x, "") <- double t = Number $ fromFloatDigits x
221+ | Right (x, "") <- signed decimal t = Number $ I x
222+ | Right (x, "") <- double t = Number $ D x
214 | otherwise = String t
224 | otherwise = String t
215 where x `isLike` ref = x `elem` [ref, T.toUpper ref, titleCased]
225 where x `isLike` ref = x `elem` [ref, T.toUpper ref, titleCased]
216 where titleCased = toUpper (T.head ref) `T.cons` T.tail ref
226 where titleCased = toUpper (T.head ref) `T.cons` T.tail ref