Revision f3f76ccc htools/Ganeti/HTools/JSON.hs
b/htools/Ganeti/HTools/JSON.hs | ||
---|---|---|
33 | 33 |
, fromJVal |
34 | 34 |
, asJSObject |
35 | 35 |
, asObjectList |
36 |
, tryFromObj |
|
36 | 37 |
) |
37 | 38 |
where |
38 | 39 |
|
... | ... | |
42 | 43 |
|
43 | 44 |
import qualified Text.JSON as J |
44 | 45 |
|
46 |
import Ganeti.BasicTypes |
|
47 |
|
|
45 | 48 |
-- * JSON-related functions |
46 | 49 |
|
47 | 50 |
-- | A type alias for the list-based representation of J.JSObject. |
... | ... | |
114 | 117 |
-- | Coneverts a list of JSON values into a list of JSON objects. |
115 | 118 |
asObjectList :: (Monad m) => [J.JSValue] -> m [J.JSObject J.JSValue] |
116 | 119 |
asObjectList = mapM asJSObject |
120 |
|
|
121 |
-- | Try to extract a key from a object with better error reporting |
|
122 |
-- than fromObj. |
|
123 |
tryFromObj :: (J.JSON a) => |
|
124 |
String -- ^ Textual "owner" in error messages |
|
125 |
-> JSRecord -- ^ The object array |
|
126 |
-> String -- ^ The desired key from the object |
|
127 |
-> Result a |
|
128 |
tryFromObj t o = annotateResult t . fromObj o |
Also available in: Unified diff