data-object-json-0.3.0: Serialize JSON data to/from Haskell using the data-object library.Source codeContentsIndex
Data.Object.Json
Contents
Definition of JsonObject
Automatic scalar conversions
Encoding/decoding
Description
A simple wrapper around the json-b library which presents values inside Objects.
Synopsis
data JsonScalar
= JsonString ByteString
| JsonNumber Rational
| JsonBoolean Bool
| JsonNull
type JsonObject = Object ByteString JsonScalar
class Eq a => IsJsonScalar a where
fromJsonScalar :: JsonScalar -> a
toJsonScalar :: a -> JsonScalar
toJsonObject :: ConvertSuccess k ByteString => IsJsonScalar v => Object k v -> JsonObject
fromJsonObject :: ConvertSuccess ByteString k => IsJsonScalar v => JsonObject -> Object k v
encode :: (ConvertSuccess k ByteString, IsJsonScalar v) => Object k v -> ByteString
encodeFile :: (ConvertSuccess k ByteString, IsJsonScalar v) => FilePath -> Object k v -> IO ()
decode :: Failure JsonDecodeError m => ConvertSuccess ByteString k => IsJsonScalar v => ByteString -> m (Object k v)
decodeFile :: Failure JsonDecodeError m => ConvertSuccess ByteString k => IsJsonScalar v => FilePath -> IO (m (Object k v))
Definition of JsonObject
data JsonScalar Source
Matches the scalar data types used in json-b so we can have proper mapping between the two libraries.
Constructors
JsonString ByteString
JsonNumber Rational
JsonBoolean Bool
JsonNull
show/hide Instances
type JsonObject = Object ByteString JsonScalarSource
Meant to match closely with the JSON data type. Therefore, uses strict byte strings for keys and the JsonScalar type for scalars.
Automatic scalar conversions
class Eq a => IsJsonScalar a whereSource
Methods
fromJsonScalar :: JsonScalar -> aSource
toJsonScalar :: a -> JsonScalarSource
show/hide Instances
toJsonObject :: ConvertSuccess k ByteString => IsJsonScalar v => Object k v -> JsonObjectSource
fromJsonObject :: ConvertSuccess ByteString k => IsJsonScalar v => JsonObject -> Object k vSource
Encoding/decoding
encode :: (ConvertSuccess k ByteString, IsJsonScalar v) => Object k v -> ByteStringSource
Encode a JsonObject into a lazy bytestring.
encodeFile :: (ConvertSuccess k ByteString, IsJsonScalar v) => FilePath -> Object k v -> IO ()Source
decode :: Failure JsonDecodeError m => ConvertSuccess ByteString k => IsJsonScalar v => ByteString -> m (Object k v)Source
Decode a lazy bytestring into a JsonObject.
decodeFile :: Failure JsonDecodeError m => ConvertSuccess ByteString k => IsJsonScalar v => FilePath -> IO (m (Object k v))Source
Produced by Haddock version 2.6.1