ReviewBoard-0.2.1: Haskell bindings to ReviewBoardSource codeContentsIndex
ReviewBoard.Response
Portabilityportable
Stabilityexperimental
Maintaineradam.smyczek@gmail.com
Contents
JSON response utils
Basic Response DSL
Description
This is an optional module that provides additional functionality to simplify handling of ReviewBoard responses.
Synopsis
js4name :: String -> JSValue -> Maybe JSValue
js4path :: [String] -> JSValue -> Maybe JSValue
js4spath :: String -> JSValue -> Maybe JSValue
js2v :: JSON a => JSValue -> a
mkrb :: JSON a => String -> JSValue -> a
JSON response utils
js4name :: String -> JSValue -> Maybe JSValueSource
Get value for name from a JSObject or Nothing if JSValue is not a JSObject
js4path :: [String] -> JSValue -> Maybe JSValueSource
Get JSValue for name path, for example for JSON object '{ "obj1" : { "str" : "test" } }' js4path ["obj1", "str"] returns Just test
js4spath :: String -> JSValue -> Maybe JSValueSource
Get JSValue for string path of the form reviewrequests.5.delete. Dots inside a name are not supported.
js2v :: JSON a => JSValue -> aSource
Extract value from JSValue or throw error
Basic Response DSL

The DSL provides a function for most ReviewBoard JSObject members that directly returns the value of the member. The function name is equivalent to the name of the member element, for example values of a response:

 { "stat": "fail", 
   "err": {
     "msg": "You are not logged in", 
     "code": 103
   }
 }

may be accessed as following:

 (msg . err) response
 -- returns 'You are not logged in' :: String
 (code . err) response
 -- returns 103 :: Integer

If the entry name represented by the function does not exist, an error is thrown.

The current function list is build by screen scraping ReviewBoard source code, so it's likely that some elements are missing. The missing function can be added using mkrb function. Please drop me an email if you find one and I will include this in the next version.

This approach for handling responses may change if I find a way to generate the DSL methods directly from ReviewBoard code.

mkrb :: JSON a => String -> JSValue -> aSource
Constructor for DSL functions
Produced by Haddock version 2.3.0