I have a jax-rs web services on jetty+jersey and tried different JSON message providers (e.g. Jackson and Gson). With all of them POJO <-> JSON works just fine but methods like this:
@GET
@Path("test")
@Produces(MediaType.APPLICATION_JSON)
public String test() {
return "This string should be \"quoted\" by message writer";
}
produce string
This string should be "quoted" by message writer
which is of course not a valid JSON and causes browser's ajax calls to fail. I expect it to be
"This string should be \"quoted\" by message writer"
The reason for such magic is StringMessageProvider (one of the internal jersey providers for basic types) which have / Produce/Consume annotation. And I don't want to hack into jersey internal providers. I want to force jersey to use JSON provider in first place?
Any ideas?