How can I make Apache Wink to return something like
{ Message: "Hello World!" }
I have the following code:
@Asset
public class Hello {
protected String message;
public Hello() {
}
@Produces(MediaType.APPLICATION_JSON)
public String getMessage() {
return message;
}
@Consumes(MediaType.APPLICATION_JSON)
public void setMessage(String message) {
this.message = message;
}
}
@Path("/helloworld")
public class HelloWorldResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Hello getMessage() {
Hello hello = new Hello();
hello.setMessage("Hello World!");
return hello;
}
}
and the server returns only "Hello World!". How can I make it return JSON that have a structure similar with the java class?
Hello
is not an asset, it's a domain class. So you don't need to annotate it.Also make sure that you have some json support (I think having Jackson is preferred). By default there is no JSON provided registered.