Is possible to custom the json output when using RestEasy?
vladimiralbis May 15, 2012 6:08 PMHi, i am testing the use of Resteasy in Seam 2 and JBoss 5.1.x.
I know that:
"RESTEasy uses JAXB to marshall entities. Thus, in order to be able to transfer
them over the wire, you need to annotate entity classes with @XMLRootElement".
Is it possible to format the json output regarding the @XMLRootElement.
My class
@XmlRootElement(name = "") @XmlAccessorType(XmlAccessType.FIELD) public class TimeLineDataJson { @XmlElement private String dateTimeFormat; @XmlElement private String wikiURL; @XmlElement private String wikiSection; @XmlElement private ArrayList<EventDataJson> events;
The output is
{"timeLineDataJson": {"dateTimeFormat":"Gregorian", "wikiURL":"http:\/\/simile.mit.edu\/shelf\/", "wikiSection":"My Tasks", "events":[ {"description":"Implement CRUD for User.", "durationEvent":true, "end":"We May 30 2012 09:00:00 GMT-0600", "image":"img\/btnnewuser.png", "start":"Mo May 28 2012 09:00:00 GMT-0600", "title":"CRUD operation for User"}, {"description":"Implement web services.", "durationEvent":true, "end":"We Jun 6 2012 09:00:00 GMT-0600", "image":"img\/btnnewuser.png", "start":"Mo Jun 4 2012 09:00:00 GMT-0600", "title":"My new task"} ] } }
I don't want the root element to be added in the output.
Expected result
{ "dateTimeFormat":"Gregorian", "wikiURL":"http:\/\/simile.mit.edu\/shelf\/", "wikiSection":"My Tasks", "events":[ {"description":"Implement CRUD for User.", "durationEvent":true, "end":"We May 30 2012 09:00:00 GMT-0600", "image":"img\/btnnewuser.png", "start":"Mo May 28 2012 09:00:00 GMT-0600", "title":"CRUD operation for User"}, {"description":"Implement web services.", "durationEvent":true, "end":"We Jun 6 2012 09:00:00 GMT-0600", "image":"img\/btnnewuser.png", "start":"Mo Jun 4 2012 09:00:00 GMT-0600", "title":"My new task"} ] }
Is this possible?