{-# OPTIONS_GHC -fno-warn-dodgy-exports -fno-warn-duplicate-exports #-}
module Autodocodec.Aeson
(
encodeJSONViaCodec,
eitherDecodeJSONViaCodec,
toJSONViaCodec,
toJSONVia,
toEncodingViaCodec,
toEncodingVia,
toJSONObjectViaCodec,
toJSONObjectVia,
toSeriesViaCodec,
toSeriesVia,
parseJSONViaCodec,
parseJSONVia,
parseJSONObjectViaCodec,
parseJSONObjectVia,
module Autodocodec.Aeson.Decode,
module Autodocodec.Aeson.Encode,
)
where
import Autodocodec.Aeson.Decode
import Autodocodec.Aeson.Encode
import Autodocodec.Class
import Autodocodec.DerivingVia
import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy as LB
encodeJSONViaCodec :: (HasCodec a) => a -> LB.ByteString
encodeJSONViaCodec :: forall a. HasCodec a => a -> ByteString
encodeJSONViaCodec = Autodocodec a -> ByteString
forall a. ToJSON a => a -> ByteString
Aeson.encode (Autodocodec a -> ByteString)
-> (a -> Autodocodec a) -> a -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Autodocodec a
forall a. a -> Autodocodec a
Autodocodec
eitherDecodeJSONViaCodec :: (HasCodec a) => LB.ByteString -> Either String a
eitherDecodeJSONViaCodec :: forall a. HasCodec a => ByteString -> Either String a
eitherDecodeJSONViaCodec = (Autodocodec a -> a)
-> Either String (Autodocodec a) -> Either String a
forall a b. (a -> b) -> Either String a -> Either String b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Autodocodec a -> a
forall a. Autodocodec a -> a
unAutodocodec (Either String (Autodocodec a) -> Either String a)
-> (ByteString -> Either String (Autodocodec a))
-> ByteString
-> Either String a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Either String (Autodocodec a)
forall a. FromJSON a => ByteString -> Either String a
Aeson.eitherDecode