I have been doing it successfully in RESTEasy. I have it set up to consume and produce both XML and JSON. Here is a request handler:
@POST
@Produces(["application/json","application/xml"])
@Consumes(["application/json","application/xml"])
@Path("/create")
public Response postCreate(
ReqData reqData) {
log.debug("data.name is "+ data.getName());
...
return Response.status(Response.Status.CREATED)
.entity(whatever)
.location(whateverURI)
.build();
}
ReqData is a JavaBean, i.e. it has a default constructor and it has setters and getters that the marshaller finds. I don't have any special JSON tags in ReqData, but I do have @XmlRootElement(name="data") at the top for the XML marshaller and @XmlElement tags on the setters.
I use separate beans for input and output, but as far as I know you can use the same bean.
The client program sends the JSON string in the entity-body of the request, and sets the Context-Type and Accept headers both to "application/json".