diff --git a/Data/CaseInsensitive/Internal.hs b/Data/CaseInsensitive/Internal.hs index cfe1291..0851d8f 100644 --- a/Data/CaseInsensitive/Internal.hs +++ b/Data/CaseInsensitive/Internal.hs @@ -32,6 +32,7 @@ module Data.CaseInsensitive.Internal ( CI -- from base: import Control.Applicative (Applicative) +import Data.Aeson ( FromJSON, parseJSON ) import Data.Bool ( (||) ) import Data.Char ( Char, toLower ) import Data.Eq ( Eq, (==) ) @@ -141,6 +142,9 @@ instance Hashable s => Hashable (CI s) where instance NFData s => NFData (CI s) where rnf (CI o f) = o `deepseq` f `deepseq` () +instance (FromJSON s, FoldCase s) => FromJSON (CI s) where + parseJSON = fmap mk . parseJSON + -------------------------------------------------------------------------------- -- Folding (lowering) cases -------------------------------------------------------------------------------- diff --git a/case-insensitive.cabal b/case-insensitive.cabal index 3746959..94628ef 100644 --- a/case-insensitive.cabal +++ b/case-insensitive.cabal @@ -38,6 +38,7 @@ Library , text >= 0.3 , deepseq >= 1.1 , hashable >= 1.0 + , aeson >= 1.0 if !impl(ghc >= 8.0) build-depends: semigroups >= 0.18 exposed-modules: Data.CaseInsensitive, Data.CaseInsensitive.Unsafe