diff --git a/glabrous.cabal b/glabrous.cabal
--- a/glabrous.cabal
+++ b/glabrous.cabal
@@ -1,5 +1,5 @@
 name:                glabrous
-version:             2.0.4
+version:             2.0.5
 synopsis:            A template DSL library
 description:         A minimalistic, Mustache-like syntax, truly logic-less,
                      pure Text template DSL library
@@ -25,7 +25,7 @@
   exposed-modules:     Text.Glabrous
                      , Text.Glabrous.Types
   other-modules:       Text.Glabrous.Internal
-  build-depends:       aeson >= 0.8.0.2 && < 1.6
+  build-depends:       aeson >= 0.8.0.2 && < 1.6 || == 2.0.*
                      , aeson-pretty >= 0.7.2 && < 0.9
                      , attoparsec >= 0.12.1.6 && < 0.15
                      , base >= 4.8.1.0 && < 5
diff --git a/src/Text/Glabrous/Types.hs b/src/Text/Glabrous/Types.hs
--- a/src/Text/Glabrous/Types.hs
+++ b/src/Text/Glabrous/Types.hs
@@ -1,9 +1,13 @@
+{-# LANGUAGE CPP               #-}
+{-# LANGUAGE DeriveGeneric     #-}
 {-# LANGUAGE OverloadedStrings #-}
-{-# LANGUAGE DeriveGeneric #-}
 
 module Text.Glabrous.Types where
 
 import           Data.Aeson
+#if MIN_VERSION_aeson(2,0,0)
+import qualified Data.Aeson.KeyMap    as KM
+#endif
 import qualified Data.HashMap.Strict as H
 import qualified Data.Text           as T
 import           Data.Serialize
@@ -32,11 +36,19 @@
 
 instance ToJSON Context where
   toJSON (Context h) =
+#if MIN_VERSION_aeson(2,0,0)
+    object (second String <$> KM.toList (KM.fromHashMapText h))
+#else
     object (second String <$> H.toList h)
+#endif
 
 instance FromJSON Context where
   parseJSON (Object o) = return
+#if MIN_VERSION_aeson(2,0,0)
+    Context { variables = H.fromList ((\(k,String v) -> (k,v)) <$> H.toList (KM.toHashMapText o)) }
+#else
     Context { variables = H.fromList ((\(k,String v) -> (k,v)) <$> H.toList o) }
+#endif
   parseJSON _          = fail "expected an object"
 
 data Result
