|
From: <Mic...@De...> - 2011-07-21 19:39:45
|
Hi folks,
I am working on a new project in which we will expose a restful webservice which returns json, and our stack is JBoss AS6, Weld 1.1.0.Final, and we are using RestEasy to provide the REST layer. I am trying to use the @Produces annotations to return json, and I'm having some luck, but would like to be able to tweak what is returned using either @Json* or JAXB annations. As it currently stands, these annotations don't seem to be having any effect....
For example, given the following annotated pojo:
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
@XmlRootElement(name = "volume")
public class Volume
{
String name;
String description;
long sizeInMB;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlTransient
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public long getSizeInMB() {
return sizeInMB;
}
public void setSizeInMB(long sizeInMB) {
this.sizeInMB = sizeInMB;
}
public Volume(String name, String description, long sizeInMB) {
super();
this.name = name;
this.description = description;
this.sizeInMB = sizeInMB;
}
public Volume() {
super();
}
}
I would expect a call returning a volume to give me something like:
{ volume: {"name":"Volume with ID: 15","sizeInMB":1500000} }
But in reality it is ignoring the JAXB annotations and providing
{"name":"Volume with ID: 15","description":"This is a sample Volume","sizeInMB":1500000}
Would you expect usage within weld to ignore the annotations? Is there any way to enable them?
Thanks!
Mike
|