Commits

basvandijk committed c92feaf

Refactor the FromJSON instance of Fixed

Comments (0)

Files changed (1)

Data/Aeson/Types/Class.hs

     {-# INLINE toJSON #-}
 
 instance HasResolution a => FromJSON (Fixed a) where
-    parseJSON (Number s) = pure $ realToFrac s
-    parseJSON v          = typeMismatch "Fixed" v
+    parseJSON = withScientific "Fixed" $ pure . realToFrac
     {-# INLINE parseJSON #-}
 
 instance ToJSON Int where