on master help sign in
Merge pull request #584 from Daniel-Diaz/master
f5b37b1Adam Bergmark
Data/Aeson/Types/FromJSON.hs+4
@@ -109,6 +109,7 @@ import Data.Vector (Vector)
109import Data.Version (Version, parseVersion)
109import Data.Version (Version, parseVersion)
110import Data.Word (Word16, Word32, Word64, Word8)
110import Data.Word (Word16, Word32, Word64, Word8)
111import Foreign.Storable (Storable)
111import Foreign.Storable (Storable)
112+import Foreign.C.Types (CTime (..))
112import GHC.Generics
113import GHC.Generics
113import Numeric.Natural (Natural)
114import Numeric.Natural (Natural)
114import Text.ParserCombinators.ReadP (readP_to_S)
115import Text.ParserCombinators.ReadP (readP_to_S)
@@ -1351,6 +1352,9 @@ instance FromJSON Word64 where
1351instance FromJSONKey Word64 where
1352instance FromJSONKey Word64 where
1352 fromJSONKey = FromJSONKeyTextParser $ parseBoundedIntegralText "Word64"
1353 fromJSONKey = FromJSONKeyTextParser $ parseBoundedIntegralText "Word64"
1353
1354
1355+instance FromJSON CTime where
1356+ parseJSON = fmap CTime . parseJSON
1357+ {-# INLINE parseJSON #-}
1354
1358
1355instance FromJSON Text where
1359instance FromJSON Text where
1356 parseJSON = withText "Text" pure
1360 parseJSON = withText "Text" pure
Data/Aeson/Types/ToJSON.hs+7−1
@@ -91,6 +91,7 @@ import Data.Vector (Vector)
91import Data.Version (Version, showVersion)
91import Data.Version (Version, showVersion)
92import Data.Word (Word16, Word32, Word64, Word8)
92import Data.Word (Word16, Word32, Word64, Word8)
93import Foreign.Storable (Storable)
93import Foreign.Storable (Storable)
94+import Foreign.C.Types (CTime (..))
94import GHC.Generics
95import GHC.Generics
95import Numeric.Natural (Natural)
96import Numeric.Natural (Natural)
96import qualified Data.Aeson.Encoding as E
97import qualified Data.Aeson.Encoding as E
@@ -1366,7 +1367,6 @@ instance ToJSONKey Int64 where
1366 toJSONKey = toJSONKeyTextEnc E.int64Text
1367 toJSONKey = toJSONKeyTextEnc E.int64Text
1367 {-# INLINE toJSONKey #-}
1368 {-# INLINE toJSONKey #-}
1368
1369
1369−
1370instance ToJSON Word where
1370instance ToJSON Word where
1371 toJSON = Number . fromIntegral
1371 toJSON = Number . fromIntegral
1372 {-# INLINE toJSON #-}
1372 {-# INLINE toJSON #-}
@@ -1426,6 +1426,12 @@ instance ToJSONKey Word64 where
1426 toJSONKey = toJSONKeyTextEnc E.word64Text
1426 toJSONKey = toJSONKeyTextEnc E.word64Text
1427 {-# INLINE toJSONKey #-}
1427 {-# INLINE toJSONKey #-}
1428
1428
1429+instance ToJSON CTime where
1430+ toJSON (CTime i) = toJSON i
1431+ {-# INLINE toJSON #-}
1432+
1433+ toEncoding (CTime i) = toEncoding i
1434+ {-# INLINE toEncoding #-}
1429
1435
1430instance ToJSON Text where
1436instance ToJSON Text where
1431 toJSON = String
1437 toJSON = String