summaryrefslogtreecommitdiffhomepage
path: root/Gpg
diff options
context:
space:
mode:
authorTony Zorman <soliditsallgood@mailbox.org>2022-03-24 10:58:13 +0100
committerJoey Hess <joeyh@joeyh.name>2022-03-24 11:33:28 -0400
commitc7bae27f009ccaae4d365dc2471c0725de2f5793 (patch)
treecec365633151a0d51a35b07a474d87005885c3ae /Gpg
parent342d4dea8496b62d0b9f4567675fab9e152da8f6 (diff)
downloaddebug-me-c7bae27f009ccaae4d365dc2471c0725de2f5793.tar.gz
Support aeson 2.0
As per the aeson 2.0.0.0 changelog[1], starting with that version the map type used by Object is now abstract, as is the key type of that map. Related: https://github.com/haskell/aeson/pull/866 Related: https://github.com/haskell/aeson/pull/868 [1]: https://hackage.haskell.org/package/aeson-2.0.0.0/changelog
Diffstat (limited to 'Gpg')
-rw-r--r--Gpg/Wot.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/Gpg/Wot.hs b/Gpg/Wot.hs
index 2a6d541..d916ebc 100644
--- a/Gpg/Wot.hs
+++ b/Gpg/Wot.hs
@@ -3,6 +3,7 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
-- | Gpg web of trust checking, using wotsap's JSON output
@@ -15,8 +16,13 @@ import JSON
import Network.HTTP.Client
import Network.HTTP.Client.TLS
import Data.List
-import qualified Data.HashMap.Strict as M
import qualified Data.Text as T
+#if MIN_VERSION_aeson(2, 0, 0)
+import qualified Data.Aeson.KeyMap as AM
+import qualified Data.Aeson.Key as AK
+#else
+import qualified Data.HashMap.Strict as M
+#endif
data WotStats = WotStats
{ key :: Node
@@ -43,9 +49,14 @@ data Node = Node
-- | wotsap's json has some upper-case fields; lowercase field for parsing
jsonLower :: Value -> Value
+#if MIN_VERSION_aeson(2, 0, 0)
+jsonLower (Object o) = Object . AM.mapKeyVal lowerKey id $ o
+ where lowerKey = AK.fromText . T.toLower . AK.toText
+#else
jsonLower (Object o) = Object . M.fromList . map lowerPair . M.toList $ o
where
lowerPair (k, v) = (T.toLower k, v)
+#endif
jsonLower x = x
instance FromJSON WotStats where