The getRequestBody method of the HttpExchange object returns an InputStream. There is still much work for correctly read the "Body". Is it a Java library + object + method that goes one more step ahead and returns the body (at the server side) as a ready-to-use Java String?
Thanks!
You can use Commons IO's
org.apache.commons.io.IOUtils.toString(InputStream, String)
to do this in one line. (It might not work with HTTP keep-alive though)Edit:
If you want to go straight to JSON, there are a bunch of Web Service stacks that will do the unmarshalling for you. Try
Spring: http://www.cribbstechnologies.com/2011/04/08/spring-mvc-ajax-web-services-part-2-attack-of-the-json-post/
CXF / JAX-RS: http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-JSONsupport
If you are using Spring MVC, you can use the @RequestBody annotation on a method parameter which is of type String. For example.
Did you try this ?