-- | Check that luxi responses contain the required keys and that the
-- call was successful.
validateResult :: String -> Result JSValue
validateResult s = do
  oarr <- fromJResult "Parsing LUXI response"
          (decodeStrict s)::Result (JSObject JSValue)
  let arr = J.fromJSObject oarr
  status <- fromObj arr (strOfKey Success)::Result Bool
  let rkey = strOfKey Result
  (if status
   then fromObj arr rkey
   else fromObj arr rkey >>= fail)

-- | Generic luxi method call.
validateResult :: String -> Result JSValue
validateResult s = do
  oarr <- fromJResult "Parsing LUXI response"
          (decodeStrict s)::Result (JSObject JSValue)
  let arr = J.fromJSObject oarr
  status <- fromObj arr (strOfKey Success)::Result Bool
  let rkey = strOfKey Result
  (if status
   then fromObj arr rkey
   else fromObj arr rkey >>= fail)

-- | Generic luxi method call.
validateResult s = do
  oarr <- fromJResult "Parsing LUXI response"
          (decodeStrict s)::Result (JSObject JSValue)
  let arr = J.fromJSObject oarr
  status <- fromObj arr (strOfKey Success)::Result Bool
  let rkey = strOfKey Result
  (if status
   then fromObj arr rkey
   else fromObj arr rkey >>= fail)

-- | Generic luxi method call.