on master help sign in
Add ToJSON and FromJSON instances for Scientific
commite2a91d9d277aa8a2d6d7d5ed33d37b13c5d730a3 authorBas van Dijk <v.dijk.bas@gmail.com> dateMon 18 Nov 2013, 09:33 (13 years ago) parent752e3ed
1 file changed+8
Data/Aeson/Types/Instances.hs+8
Data/Aeson/Types/Instances.hs+8
@@ -151,6 +151,14 @@ instance FromJSON Char where
151151 else fail "Expected a string of length 1"
152152 {-# INLINE parseJSON #-}
153153
154+instance ToJSON Scientific where
155+ toJSON = Number
156+ {-# INLINE toJSON #-}
157+
158+instance FromJSON Scientific where
159+ parseJSON = withScientific "Scientific" pure
160+ {-# INLINE parseJSON #-}
161+
154162instance ToJSON Double where
155163 toJSON = realFloatToJSON
156164 {-# INLINE toJSON #-}