@@ -46,14 +46,7 @@ import GHC.TypeLits
4646import qualified Optics.Lens as OL
4747import Unsafe.Coerce
4848import Prelude
49−#if MIN_VERSION_aeson(2,0,0)
50−import Data.Aeson.Key (fromText, fromString)
51−#else
52−fromText :: a -> a
53−fromText = id
54−fromString :: String -> T.Text
55−fromString = T.pack
56−#endif
49+import qualified Data.Aeson.Key as Key
5750
5851-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
5952-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -566,16 +559,16 @@ class ToJSON a => EncodeField a where
566559
567560instance ToJSON a => EncodeField a where
568561 encodeField = pure . toJSON
569− encodeKV k v = fromText k .= v
562+ encodeKV k v = Key.fromText k .= v
570563
571564instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
572565 encodeField = fmap toJSON
573566 encodeKV _ Nothing = mempty
574− encodeKV k v = fromText k .= v
567+ encodeKV k v = Key.fromText k .= v
575568
576569recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
577570recToValue options r =
578− object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (fromString (fieldTransform options k),) <$> encodeField v) r
571+ object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (Key.fromString (fieldTransform options k),) <$> encodeField v) r
579572
580573recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
581574recToEncoding options r =
@@ -680,10 +673,10 @@ class FromJSON a => ParseField a where
680673 parseField :: Object -> T.Text -> Parser a
681674
682675instance FromJSON a => ParseField a where
683− parseField o k = o .: fromText k
676+ parseField o k = o .: Key.fromText k
684677
685678instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
686− parseField o k = o .:? fromText k
679+ parseField o k = o .:? Key.fromText k
687680
688681instance
689682 ( KnownSymbol l,