on master help sign in
Add ToJSON and FromJSON instances for Scientific
e2a91d9Bas van Dijk
Data/Aeson/Types/Instances.hs+8
@@ -151,6 +151,14 @@ instance FromJSON Char where
151 else fail "Expected a string of length 1"
151 else fail "Expected a string of length 1"
152 {-# INLINE parseJSON #-}
152 {-# INLINE parseJSON #-}
153
153
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+
154instance ToJSON Double where
162instance ToJSON Double where
155 toJSON = realFloatToJSON
163 toJSON = realFloatToJSON
156 {-# INLINE toJSON #-}
164 {-# INLINE toJSON #-}