packages feed

generic-aeson 0.2.0.12 → 0.2.0.13

raw patch · 3 files changed

+28/−7 lines, 3 filesdep ~aesondep ~basenew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson, base

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +#### 0.2.0.13++* Allow `aeson 2.0`.+ #### 0.2.0.11  * Allow never GHC/libraries. Thanks to Alejandro Serrano!
generic-aeson.cabal view
@@ -1,5 +1,5 @@ name:                generic-aeson-version:             0.2.0.12+version:             0.2.0.13 synopsis:            Derivation of Aeson instances using GHC generics. description:         Derivation of Aeson instances using GHC generics. author:              Silk@@ -28,8 +28,8 @@     Generics.Generic.IsEnum   build-depends:       base >= 4.4 && < 4.16-    , aeson >= 0.6 && < 1.6-    , attoparsec >= 0.11 && < 0.14+    , aeson >= 0.6 && < 2.1+    , attoparsec >= 0.11 && < 0.15     , generic-deriving >= 1.6 && < 1.15     , mtl >= 2.0 && < 2.3     , tagged >= 0.2 && < 0.9
src/Generics/Generic/Aeson.hs view
@@ -45,16 +45,31 @@ import Control.Monad.State import Data.Aeson import Data.Aeson.Types hiding (GFromJSON, GToJSON)+import Data.Bifunctor (first) import Data.Proxy import Data.Text (Text) import GHC.Generics import Generics.Deriving.ConNames+#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.KeyMap   as H+#else import qualified Data.HashMap.Strict as H+#endif import qualified Data.Text           as T import qualified Data.Vector         as V  import Generics.Generic.Aeson.Util +#if MIN_VERSION_aeson(2,0,0)+import Data.Aeson.Key (fromText)+#else+-- for compatibility with aeson < 2+type Key = Text++fromText :: Text -> Key+fromText = id+#endif + -- | Class for converting the functors from "GHC.Generics" to JSON. -- You generally don't need to give any custom instances. Just add -- 'deriving Generic' and call 'gToJson'.@@ -229,8 +244,10 @@          Just n  ->            do o <- pop               case o of-                Object h | H.member n h -> error impossible <$> parser-                         | otherwise    -> return $ M1 (K1 Nothing)+                Object h | H.member (fromText n) h+                         -> error impossible <$> parser+                         | otherwise+                         -> return $ M1 (K1 Nothing)                 _ -> lift $ typeMismatch "Object" (Array V.empty)     where       parser = gparseJSONf set mc smf enm :: StateT [Value] Parser (M1 S c (K1 i a) p)@@ -243,7 +260,7 @@                   modify (o:)     Just p  -> do o <- pop                   v <- lift (withObject ("Expected property " ++ show propName ++ " in object in gparseJSONf for " ++ show cname ++ ".")-                                        (.: p) o)+                                        (.: fromText p) o)                   modify (v:)  pop :: StateT [Value] Parser Value@@ -253,4 +270,4 @@      return v  toObject :: ToJSON v => [(Text, v)] -> Value-toObject = object . map (uncurry (.=))+toObject = object . map (uncurry (.=) . first fromText)