Revision 26e32dee src/Ganeti/JSON.hs

b/src/Ganeti/JSON.hs
49 49
  , optionalJSField
50 50
  , optFieldsToObj
51 51
  , readContainer
52
  , DictObject(..)
53
  , ArrayObject(..)
52 54
  , HasStringRepr(..)
53 55
  , GenericContainer(..)
54 56
  , Container
......
326 328
  readJSON v = fail $ "Failed to load container, expected object but got "
327 329
               ++ show (pp_value v)
328 330

  
331
-- * Types that (de)serialize in a special form of JSON
332

  
333
-- | Class of objects that can be converted from and to 'JSObject'
334
-- lists-format.
335
class DictObject a where
336
  toDict :: a -> [(String, J.JSValue)]
337
  fromDict :: [(String, J.JSValue)] -> J.Result a
338

  
339
-- | Class of objects that can be converted from and to @[JSValue]@ with
340
-- a fixed length and order.
341
class ArrayObject a where
342
  toJSArray :: a -> [J.JSValue]
343
  fromJSArray :: [J.JSValue] -> J.Result a
344

  
345
-- * General purpose data types for working with JSON
346

  
329 347
-- | A Maybe newtype that allows for serialization more appropriate to the
330 348
-- semantics of Maybe and JSON in our calls. Does not produce needless
331 349
-- and confusing dictionaries.

Also available in: Unified diff