Revision 3ad57194 htools/Ganeti/HTools/JSON.hs

b/htools/Ganeti/HTools/JSON.hs
2 2

  
3 3
{-
4 4

  
5
Copyright (C) 2009, 2010, 2011 Google Inc.
5
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
6 6

  
7 7
This program is free software; you can redistribute it and/or modify
8 8
it under the terms of the GNU General Public License as published by
......
34 34
  , asJSObject
35 35
  , asObjectList
36 36
  , tryFromObj
37
  , toArray
37 38
  )
38 39
  where
39 40

  
......
126 127
           -> String     -- ^ The desired key from the object
127 128
           -> Result a
128 129
tryFromObj t o = annotateResult t . fromObj o
130

  
131
-- | Ensure a given JSValue is actually a JSArray.
132
toArray :: (Monad m) => J.JSValue -> m [J.JSValue]
133
toArray (J.JSArray arr) = return arr
134
toArray o = fail $ "Invalid input, expected array but got " ++ show o

Also available in: Unified diff