@@ -46,14 +46,6 @@ import GHC.TypeLits
46import qualified Optics.Lens as OL
46import qualified Optics.Lens as OL
47import Unsafe.Coerce
47import Unsafe.Coerce
48import Prelude
48import Prelude
49−#if MIN_VERSION_aeson(2,0,0)
50−import Data.Aeson.Key (fromText, fromString)
54−fromString :: String -> T.Text
58-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
50-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
59-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
51-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -566,16 +558,16 @@ class ToJSON a => EncodeField a where
567instance ToJSON a => EncodeField a where
559instance ToJSON a => EncodeField a where
568 encodeField = pure . toJSON
560 encodeField = pure . toJSON
569− encodeKV k v = fromText k .= v
561+ encodeKV = (.=)
571instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
563instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
572 encodeField = fmap toJSON
564 encodeField = fmap toJSON
573 encodeKV _ Nothing = mempty
565 encodeKV _ Nothing = mempty
574− encodeKV k v = fromText k .= v
566+ encodeKV k v = k .= v
576recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
568recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
577recToValue options r =
569recToValue options r =
578− object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (fromString (fieldTransform options k),) <$> encodeField v) r
570+ object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (T.pack (fieldTransform options k),) <$> encodeField v) r
580recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
572recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
581recToEncoding options r =
573recToEncoding options r =
@@ -680,10 +672,10 @@ class FromJSON a => ParseField a where
680 parseField :: Object -> T.Text -> Parser a
672 parseField :: Object -> T.Text -> Parser a
682instance FromJSON a => ParseField a where
674instance FromJSON a => ParseField a where
683− parseField o k = o .: fromText k
675+ parseField = (.:)
685instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
677instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
686− parseField o k = o .:? fromText k
678+ parseField = (.:?)
689 ( KnownSymbol l,
681 ( KnownSymbol l,