Merge pull request #8 from BeFunctional/edsko/show-json
Show instance for JSON
This commit is contained in:
commit
0bdbb0f1cb
1 changed files with 9 additions and 5 deletions
14
src/Foreign/Rust/External/JSON.hs
vendored
14
src/Foreign/Rust/External/JSON.hs
vendored
|
@ -19,11 +19,12 @@ import Codec.Borsh
|
||||||
import Foreign.Rust.Failure
|
import Foreign.Rust.Failure
|
||||||
import GHC.Stack
|
import GHC.Stack
|
||||||
|
|
||||||
import qualified Data.Aeson as Aeson
|
import qualified Data.Aeson as Aeson
|
||||||
import qualified Data.Aeson.Encoding as Aeson (unsafeToEncoding)
|
import qualified Data.Aeson.Encoding as Aeson (unsafeToEncoding)
|
||||||
import qualified Data.Aeson.Types as Aeson (parseFail)
|
import qualified Data.Aeson.Types as Aeson (parseFail)
|
||||||
import qualified Data.Binary.Builder as Binary
|
import qualified Data.Binary.Builder as Binary
|
||||||
import qualified Data.ByteString.Lazy as Lazy (ByteString)
|
import qualified Data.ByteString.Lazy as Lazy (ByteString)
|
||||||
|
import qualified Data.ByteString.Lazy.Char8 as Lazy.Char8
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
Serialisation
|
Serialisation
|
||||||
|
@ -34,6 +35,9 @@ newtype JSON = JSON Lazy.ByteString
|
||||||
deriving stock (Eq)
|
deriving stock (Eq)
|
||||||
deriving newtype (BorshSize, ToBorsh, FromBorsh)
|
deriving newtype (BorshSize, ToBorsh, FromBorsh)
|
||||||
|
|
||||||
|
instance Show JSON where
|
||||||
|
show (JSON bs) = Lazy.Char8.unpack bs
|
||||||
|
|
||||||
-- | Types with a Rust-side JSON renderer
|
-- | Types with a Rust-side JSON renderer
|
||||||
class ToJSON a where
|
class ToJSON a where
|
||||||
toJSON :: a -> JSON
|
toJSON :: a -> JSON
|
||||||
|
|
Loading…
Reference in a new issue