A simple wrapper around the json-b library which presents values inside
Object
s.
- data JsonScalar
- 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))
- data JsonDecodeError
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.
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
fromJsonScalar :: JsonScalar -> aSource
toJsonScalar :: a -> JsonScalarSource
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
Exception type
data JsonDecodeError Source
Error type for JSON decoding errors.