Spring's RestTemplate and prefix in JSON body -
i'd use resttemplate obtain response server , process response in android app, server answers prefix (or variable) in json body, response looks similar this:
response={"foo":"bar"} is possible omit "response=" part som simple way, or need reimplement mappingjacksonhttpmessageconverter class?
thanks in advance
edit: it works now, following code based on newest springandroid (1.0.0 release). restteplate(true) constructor adds required convertors , request.tomap() builds multivaluemap, body type formhttpmessageconverter accepts.
httpheaders requestheaders = new httpheaders(); requestheaders.setcontenttype(new mediatype("application", "x-www-form-urlencoded")); resttemplate resttemplate = new resttemplate(true); resttemplate.setrequestfactory(new httpcomponentsclienthttprequestfactory()); final string url = "http://www.dummy.org/herp/getderp"; string result = resttemplate.postforobject(url, request.tomap(), string.class); now have string on output, can extract json , parse that.
Comments
Post a Comment