|
From: Joe L. <joe...@gm...> - 2011-07-21 22:19:33
|
Mike, I think this may be relevant: http://jira.codehaus.org/browse/JACKSON-163 Last comment on that improvement ticket: "Implemented serialization side support, so that wrapping can be enabled easily by setting 'SerializationConfig.Feature.WRAP_ROOT_VALUE' to true. If so, extra single-property JSON Object is added; root name comes from value class or forced static type by default, but JAXB annotation introspector adds @XmlRootElement based override as necessary." Cheers On 21 July 2011 20:39, <Mic...@de...> wrote: > 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 > > > > ------------------------------------------------------------------------------ > 5 Ways to Improve & Secure Unified Communications > Unified Communications promises greater efficiencies for business. UC can > improve internal communications as well as offer faster, more efficient ways > to interact with customers and streamline customer service. Learn more! > http://www.accelacomm.com/jaw/sfnl/114/51426253/ > _______________________________________________ > Resteasy-users mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-users > > |