graphql-engine/server/src-lib/Data/Aeson/Extended.hs
Antoine Leblanc d8c56a40f6 server: split boolean operators between core and backend-specific
GitOrigin-RevId: f1291946a1122220e82371676d88867fd7b2b7c4
2021-03-25 17:51:08 +00:00

34 lines
793 B
Haskell

module Data.Aeson.Extended
( module J
, encodeToStrictText
, ToJSONKeyValue (..)
, FromJSONKeyValue (..)
) where
import Hasura.Prelude
import qualified Data.Aeson.Text as JT
import qualified Data.Text.Lazy as LT
import Data.Aeson as J
import Data.Aeson.Types (Parser)
import Data.Functor.Const
encodeToStrictText :: (ToJSON a) => a -> Text
encodeToStrictText = LT.toStrict . JT.encodeToLazyText
class ToJSONKeyValue a where
toJSONKeyValue :: a -> (Text, J.Value)
class FromJSONKeyValue a where
parseJSONKeyValue :: (Text, J.Value) -> Parser a
instance ToJSONKeyValue Void where
toJSONKeyValue = absurd
instance ToJSONKeyValue a => ToJSONKeyValue (Const a b) where
toJSONKeyValue = toJSONKeyValue . getConst