+parseData :: String -> Either String (String, String)
+parseData body =
+ let
+ decoded = resultToEither $ decodeStrict body
+ obj = decoded -- decoded `combineEithers` fromJSObject
+ request = obj `combineEithers` getObjectElement "request"
+ rname = request `combineEithers` getStringElement "name"
+ ilist = obj `combineEithers` getObjectElement "instances"
+ nlist = obj `combineEithers` getObjectElement "nodes"
+ idata = applyEither1 fromJSObject ilist
+ ndata = applyEither1 fromJSObject nlist
+ iobj = idata `combineEithers` (ensureEitherList .
+ map (\(x,y) ->
+ asJSObject y `combineEithers`
+ parseInstance x))
+ ilines = iobj `combineEithers` (Right . unlines)
+ nobj = ndata `combineEithers` (ensureEitherList .
+ map (\(x,y) ->
+ asJSObject y `combineEithers`
+ parseNode x))
+ nlines = nobj `combineEithers` (Right . unlines)
+ in applyEither2 (,) nlines ilines