@@ -43,17 +43,11 @@ import GHC.OverloadedLabels
43import GHC.Prim
43import GHC.Prim
44import GHC.ST (ST (..), runST)
44import GHC.ST (ST (..), runST)
45import GHC.TypeLits
45import GHC.TypeLits
46+import Generic.Data (gshowsPrec)
47+import Generic.Data.Internal.Show (GShow)
46import qualified Optics.Lens as OL
48import qualified Optics.Lens as OL
47import Unsafe.Coerce
49import Unsafe.Coerce
48import Prelude
50import 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.
52-- | Field named @l@ labels value of type @t@ adapted from the awesome /labels/ package.
59-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
53-- Example: @(#name := \"Chris\") :: (\"name\" := String)@
@@ -566,16 +560,16 @@ class ToJSON a => EncodeField a where
567instance ToJSON a => EncodeField a where
561instance ToJSON a => EncodeField a where
568 encodeField = pure . toJSON
562 encodeField = pure . toJSON
569− encodeKV k v = fromText k .= v
563+ encodeKV = (.=)
571instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
565instance {-# OVERLAPS #-} ToJSON a => EncodeField (Maybe a) where
572 encodeField = fmap toJSON
566 encodeField = fmap toJSON
573 encodeKV _ Nothing = mempty
567 encodeKV _ Nothing = mempty
574− encodeKV k v = fromText k .= v
568+ encodeKV k v = k .= v
576recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
570recToValue :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Value
577recToValue options r =
571recToValue options r =
578− object $ catMaybes $ reflectRec @EncodeField Proxy (\k v -> (fromString (fieldTransform options k),) <$> encodeField v) r
572+ 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
574recToEncoding :: forall lts. (RecApply lts lts EncodeField) => JSONOptions -> Rec lts -> Encoding
581recToEncoding options r =
575recToEncoding options r =
@@ -680,10 +674,10 @@ class FromJSON a => ParseField a where
680 parseField :: Object -> T.Text -> Parser a
674 parseField :: Object -> T.Text -> Parser a
682instance FromJSON a => ParseField a where
676instance FromJSON a => ParseField a where
683− parseField o k = o .: fromText k
677+ parseField = (.:)
685instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
679instance {-# OVERLAPS #-} FromJSON a => ParseField (Maybe a) where
686− parseField o k = o .:? fromText k
680+ parseField = (.:?)
689 ( KnownSymbol l,
683 ( KnownSymbol l,