|
From: Jesus M. R. <jm...@gm...> - 2010-03-16 12:59:00
|
Thanks for responding again Lars. If I take out (name = "jsontest"), the resulting JSON actually uses the classname: jsonTestObject. Any other ideas as to how to get it to generate "natural" json? jesus On Tue, Mar 16, 2010 at 2:48 AM, Lars Ræder Clausen <lr...@am...> wrote: > I would say it's because you're naming the object in @XmlRootElement. > > -Lars > > On Mon, Mar 15, 2010 at 9:25 PM, Jesus M. Rodriguez <jm...@gm...> wrote: >> Lars, >> >> Sure here's the JsonTestObject code: http://pastie.org/870667 >> >> jesus >> >> On Mon, Mar 15, 2010 at 4:20 PM, Lars Ræder Clausen <lr...@am...> wrote: >>> Yes, there is, we do it. But it might interfere with the way you get >>> your XML. Without seeing your JsonTestObject class, I can't tell why >>> it's doing it that way. >>> >>> -Lars >>> >>> On Mon, Mar 15, 2010 at 7:55 PM, Jesus M. Rodriguez <jm...@gm...> wrote: >>>> I'm looking at switching from jersey to resteasy. I have an object >>>> that is annotated with jaxb. >>>> I have a TestResource class that I want to produce both XML and natural json. >>>> >>>> @GET >>>> @Path("/gettest") >>>> @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) >>>> public JsonTestObject gettest() { >>>> >>>> JsonTestObject parent1 = new JsonTestObject(); >>>> parent1.setName("parent1"); >>>> parent1.setStringList(new ArrayList<String>()); >>>> parent1.setParent(null); >>>> >>>> List<String> stringlist = new ArrayList<String>(); >>>> stringlist.add("string2"); >>>> stringlist.add("string3"); >>>> JsonTestObject parent = new JsonTestObject(); >>>> parent.setName("parentname"); >>>> parent.setParent(parent1); >>>> parent.setStringList(stringlist); >>>> >>>> stringlist.add("child"); >>>> JsonTestObject jto1 = new JsonTestObject(); >>>> jto1.setName("myname"); >>>> jto1.setParent(parent); >>>> jto1.setStringList(stringlist); >>>> >>>> >>>> return jto1; >>>> } >>>> >>>> In jersey, I get natural json: >>>> >>>> testjsonobject get: >>>> {"name":"myname","parent":{"name":"parentname","parent":{"name":"parent1"},"stringList":["string2","string3","child"]},"stringList":["string2","string3","child"]} >>>> >>>> but with resteasy, I get the mapped jettison format: >>>> >>>> testjsonobject get: >>>> {"jsontest":{"name":"myname","parent":[{"name":"parentname"},{"name":"parent1"}]},"stringList":["string2","string3","child","string2","string3","child"]} >>>> >>>> Is there a way to get the xml and "natural" json support with resteasy? >>>> >>>> Sincerely, >>>> jesus rodriguez >>>> >>>> ------------------------------------------------------------------------------ >>>> Download Intel® Parallel Studio Eval >>>> Try the new software tools for yourself. Speed compiling, find bugs >>>> proactively, and fine-tune applications for parallel performance. >>>> See why Intel Parallel Studio got high marks during beta. >>>> http://p.sf.net/sfu/intel-sw-dev >>>> _______________________________________________ >>>> Resteasy-users mailing list >>>> Res...@li... >>>> https://lists.sourceforge.net/lists/listinfo/resteasy-users >>>> >>> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Resteasy-users mailing list >> Res...@li... >> https://lists.sourceforge.net/lists/listinfo/resteasy-users >> > |