summaryrefslogtreecommitdiffhomepage
path: root/Gpg/Wot.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Gpg/Wot.hs')
-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