在根据请求设置正文时,我可以在 Groovy 的 HTTPBuilder 中使用 Jackson 而不是 JSON-lib 吗?
例子:
client.request(method){
uri.path = path
requestContentType = JSON
body = customer
response.success = { HttpResponseDecorator resp, JSONObject returnedUser ->
customer = getMapper().readValue(returnedUser.content[0].toString(), Customer.class)
return customer
}
}
在这个例子中,我在处理响应时很好地使用了 Jackson,但我相信请求使用的是 JSON-lib。