users@jersey.java.net

Re: [Jersey] _at_XmlRootElement not shown in a JSON response

From: Grover Blue <grover.blue_at_gmail.com>
Date: Mon, 24 Aug 2009 10:42:35 -0400

I don't know what you mean by "convention"

On Sun, Aug 23, 2009 at 10:32 AM, Tatu Saloranta <tsaloranta_at_gmail.com>wrote:

> Doesn't that depend on which convention is being used? For some it
> should, for others not -- it's not strictly required information.
>
> -+ Tatu +-
>
> On Fri, Aug 21, 2009 at 9:30 AM, Grover Blue<grover.blue_at_gmail.com> wrote:
> > Shouldn't the root "record" be included with a JSON response?
> >
> > @XmlRootElement(name="record")
> > public class ReturnedClass {
> >
> > private String term;
> > private Date time;
> >
> > @XmlElement(name="searchTerm")
> > public String getTerm() { return term; }
> >
> > @XmlTransient
> > public Date getTime() { return time; }
> >
> > @XmlElement(name="searchTime")
> > public long getTimeInMilliseconds() { return time.getTime();}
> >
> > }
> >
> >
> > Result:
> > {
> > "searchTerm":"myTerm",
> > "searchTime":"987654321"
> > }
> >
> > Expected:
> > {
> > "record" : {
> > "searchTerm":"myTerm",
> > "searchTime":"987654321"
> > }
> > }
> >
> >
> > This is the resource method:
> >
> > @GET
> > @Path("/myPath/{searchTerm}/{searchTime}")
> > @Produces("application/json")
> > public ReturnedClass getResult(@PathParam("searchTerm") String term,
> > @PathParam("searchTime") long
> > milliseconds) {
> > ReturnedClass rc = new ReturnedClass();
> > rc.setTerm(term);
> > rc.setTime(new Date(milliseconds));
> > return rc;
> > }
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>


-- 
“If the American people ever allow private banks to control the issue of
their currency, first by inflation, then by deflation, the banks...will
deprive the people of all property until their children wake-up homeless on
the continent their fathers conquered... The issuing power should be taken
from the banks and restored to the people, to whom it properly belongs."
-- Thomas Jefferson
"Government big enough to supply everything...is big enough to take
everything you have. The course of history shows that as a government grows,
liberty decreases" --- Thomas Jefferson
www.CampaignForLiberty.org