[json-lib-user] Groovy HTTPBuilder + JSON Parsing Error
Brought to you by:
aalmiray
From: Ronald R. D. <ron...@gm...> - 2009-03-13 13:59:39
|
All, I am attempting to do the following with Groovy: http.request( GET, JSON ) { url.query = [ sourceName:'avm://portal--admin/-1;www;avm_webapps;ROOT;DCP_4963.JPG', destName:'HHMI Documents/images', name:'ronCopy.jpg', remove:'false' ] requestContentType : JSON // response handler for a success response code: response.success = { resp, json -> println resp.statusLine // parse the JSON response object: json.responseData.results.each { println " ${it.titleNoFormatting} : ${it.visibleUrl}" } } // handler for any failure status code: response.failure = { resp -> println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}" } } The response JSON looks like the following: { "node" : { "projectOverviewLocation" : "workspace://SpacesStore/d83b8a9b-8685-40d4-b045-5def043b85a5" } } Which to me looks like valid JSON, but I get the following exception: Exception thrown: Invalid JSON String net.sf.json.JSONException: Invalid JSON String at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:143) at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:103) at net.sf.json.groovy.JsonSlurper.parseText(JsonSlurper.java:78) at groovyx.net.http.ParserRegistry.parseJSON(ParserRegistry.java:185) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:461) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:407) at groovyx.net.http.HTTPBuilder.request(HTTPBuilder.java:360) at ConsoleScript52.run(ConsoleScript52:9) Any reason why that might be occurring? -- Ron DiFrango http://rdifrango.blogspot.com/ |