Copyright | (c) Edsko de Vries Duncan Coutts 2015 |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Type classes and utilities for converting to and from
JSValue
.
Synopsis
- class ToJSON m a where
- class FromJSON m a where
-
class
ToObjectKey
m a
where
- toObjectKey :: a -> m JSString
-
class
FromObjectKey
m a
where
- fromObjectKey :: JSString -> m ( Maybe a)
- class ( Applicative m, Monad m) => ReportSchemaErrors m where
- type Expected = String
- type Got = String
- expectedButGotValue :: ReportSchemaErrors m => Expected -> JSValue -> m a
- fromJSObject :: ReportSchemaErrors m => JSValue -> m [( JSString , JSValue )]
- fromJSField :: ( ReportSchemaErrors m, FromJSON m a) => JSValue -> JSString -> m a
- fromJSOptField :: ( ReportSchemaErrors m, FromJSON m a) => JSValue -> JSString -> m ( Maybe a)
- mkObject :: forall m. Monad m => [( JSString , m JSValue )] -> m JSValue
Type classes
class ToJSON m a where Source #
Instances
Monad m => ToJSON m Int54 Source # | |
Monad m => ToJSON m String Source # | |
Monad m => ToJSON m JSString Source # | |
Monad m => ToJSON m JSValue Source # | |
( Monad m, ToJSON m a) => ToJSON m [a] Source # | |
Defined in Text.JSON.Canonical.Class |
|
( Monad m, ToObjectKey m k, ToJSON m a) => ToJSON m ( Map k a) Source # | |
class FromJSON m a where Source #
Instances
ReportSchemaErrors m => FromJSON m Int54 Source # | |
ReportSchemaErrors m => FromJSON m String Source # | |
ReportSchemaErrors m => FromJSON m JSString Source # | |
Monad m => FromJSON m JSValue Source # | |
( ReportSchemaErrors m, FromJSON m a) => FromJSON m [a] Source # | |
Defined in Text.JSON.Canonical.Class |
|
( ReportSchemaErrors m, Ord k, FromObjectKey m k, FromJSON m a) => FromJSON m ( Map k a) Source # | |
class ToObjectKey m a where Source #
toObjectKey :: a -> m JSString Source #
Instances
Monad m => ToObjectKey m String Source # | |
Defined in Text.JSON.Canonical.Class toObjectKey :: String -> m JSString Source # |
|
Monad m => ToObjectKey m JSString Source # | |
Defined in Text.JSON.Canonical.Class toObjectKey :: JSString -> m JSString Source # |
class FromObjectKey m a where Source #
fromObjectKey :: JSString -> m ( Maybe a) Source #
Instances
Monad m => FromObjectKey m String Source # | |
Defined in Text.JSON.Canonical.Class |
|
Monad m => FromObjectKey m JSString Source # | |
Defined in Text.JSON.Canonical.Class |
class ( Applicative m, Monad m) => ReportSchemaErrors m where Source #
Monads in which we can report schema errors
expectedButGotValue :: ReportSchemaErrors m => Expected -> JSValue -> m a Source #
Utility
fromJSObject :: ReportSchemaErrors m => JSValue -> m [( JSString , JSValue )] Source #
fromJSField :: ( ReportSchemaErrors m, FromJSON m a) => JSValue -> JSString -> m a Source #
Extract a field from a JSON object
fromJSOptField :: ( ReportSchemaErrors m, FromJSON m a) => JSValue -> JSString -> m ( Maybe a) Source #