fields-json-0.2.1: Abusing monadic syntax JSON objects generation.

Safe HaskellNone




Interface for extracting data from JSValue.


Basic Parsing

class FromJSValue a whereSource

Structures that can be parsed from JSON. Instances must declare either fromJSValue (parse directly from JSValue) or fromJSValueM (uses MonadReader)

Data Extraction

fromJSValueField :: (JSValueContainer c, MonadReader c m, FromJSValue a) => String -> m (Maybe a)Source

Reading the value that is on some field. With field if current JSON is not object

fromJSValueFieldBase64 :: (JSValueContainer c, MonadReader c m) => String -> m (Maybe ByteString)Source

Version of fromJSValueField for Base64 encoded data to avoid memory leak.

fromJSValueFieldCustom :: (JSValueContainer c, MonadReader c m) => String -> m (Maybe a) -> m (Maybe a)Source

Generalization of fromJSValueField. Does not use FromJSValue instances

fromJSValueCustomMany :: (JSValueContainer c, MonadReader c m) => m (Maybe a) -> m (Maybe [a])Source

Runs parser on each element of underlaying json. Returns Just iff JSON is array.

fromJSValueCustomList :: (JSValueContainer c, MonadReader c m) => [m (Maybe a)] -> m (Maybe [a])Source

Generalization of fromJSValueCustomMany, where each element of array can have different parser.


withJSValue :: Monad m => JSValue -> ReaderT JSValue m a -> m aSource

Simple runner