mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 01:44:03 +03:00
d8c56a40f6
GitOrigin-RevId: f1291946a1122220e82371676d88867fd7b2b7c4
34 lines
793 B
Haskell
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
|