I have created the following relaxation methods in my leisure based web service
@GET @Produces("application/json") @Path("plain") public String getPlain() { return "hello world"; } @GET @Produces("application/json") @Path("wrapper") public Response getWrapper() { return Response.ok(new Object(){ public String data = "hello world";}).build(); }
When I call a regular service, it returns the raw string hello world , not a formatted json handler. However, wrapping the string in the object returns json {"data": "hello world"}
Why is he exhibiting this behavior? How to send plain String as json?
orak source share