ganeti-htoolsSource codeContentsIndex
Ganeti.HTools.JSON
Contents
JSON-related functions
Description
JSON utility functions.
Synopsis
type JSRecord = [(String, JSValue)]
fromJResult :: Monad m => String -> Result a -> m a
readEitherString :: Monad m => JSValue -> m String
loadJSArray :: Monad m => String -> String -> m [JSObject JSValue]
fromObj :: (JSON a, Monad m) => JSRecord -> String -> m a
maybeFromObj :: (JSON a, Monad m) => JSRecord -> String -> m (Maybe a)
fromObjWithDefault :: (JSON a, Monad m) => JSRecord -> String -> a -> m a
fromKeyValue :: (JSON a, Monad m) => String -> JSValue -> m a
fromJVal :: (Monad m, JSON a) => JSValue -> m a
asJSObject :: Monad m => JSValue -> m (JSObject JSValue)
asObjectList :: Monad m => [JSValue] -> m [JSObject JSValue]
tryFromObj :: JSON a => String -> JSRecord -> String -> Result a
toArray :: Monad m => JSValue -> m [JSValue]
JSON-related functions
type JSRecord = [(String, JSValue)]Source
A type alias for the list-based representation of J.JSObject.
fromJResult :: Monad m => String -> Result a -> m aSource
Converts a JSON Result into a monadic value.
readEitherString :: Monad m => JSValue -> m StringSource

Tries to read a string from a JSON value.

In case the value was not a string, we fail the read (in the context of the current monad.

loadJSArraySource
:: Monad m
=> StringInput message
-> String
-> m [JSObject JSValue]
Converts a JSON message into an array of JSON objects.
fromObj :: (JSON a, Monad m) => JSRecord -> String -> m aSource
Reads the value of a key in a JSON object.
maybeFromObj :: (JSON a, Monad m) => JSRecord -> String -> m (Maybe a)Source
Reads the value of an optional key in a JSON object.
fromObjWithDefault :: (JSON a, Monad m) => JSRecord -> String -> a -> m aSource
Reads the value of a key in a JSON object with a default if missing.
fromKeyValueSource
:: (JSON a, Monad m)
=> StringThe value to read
-> JSValue
-> m a
Reads a JValue, that originated from an object key.
fromJVal :: (Monad m, JSON a) => JSValue -> m aSource
Small wrapper over readJSON.
asJSObject :: Monad m => JSValue -> m (JSObject JSValue)Source
Converts a JSON value into a JSON object.
asObjectList :: Monad m => [JSValue] -> m [JSObject JSValue]Source
Coneverts a list of JSON values into a list of JSON objects.
tryFromObjSource
:: JSON a
=> StringThe object array
-> JSRecordThe desired key from the object
-> String
-> Result a
Try to extract a key from a object with better error reporting than fromObj.
toArray :: Monad m => JSValue -> m [JSValue]Source
Ensure a given JSValue is actually a JSArray.
Produced by Haddock version 2.6.0