users@jersey.java.net

[Jersey] Re: how to rename XmlRootElement in JSON

From: Maxrunner <joao.rossa_at_gmail.com>
Date: Mon, 30 May 2011 06:24:12 -0700 (PDT)

Well that's only a way to solve my issue. I just want tho change the List
type name to one my own, like in here:

@GET

@Produces(MediaType.APPLICATION_JSON)

@Path("/getAllOrganicas")

*//SOME ANNOTATION HERE TO OVERRIDE TYPE NAME TO ONE OF MY ONWN? *

public Organicas<OrganicaMobileEntity> getOrganicas(@Context
HttpServletRequest req){
                
                List<OrganicaMobileEntity> organicas= new ArrayList<OrganicaMobileEntity>();
                //dummy data
                organicas.add(fillOrganica(123,req.getParameter("lastUpdate"),"2010-12-23",true));
                organicas.add(fillOrganica(124,"Organica Mind","2000-05-21",false));
                organicas.add(fillOrganica(125,"Organica Strength","2002-12-23",true));
                organicas.add(fillOrganica(126,"Organica Stamina","2011-06-14",true));
                organicas.add(fillOrganica(127,"Organica Luck","2006-02-01",false));
                organicas.add(fillOrganica(128,"Organica Love","2003-04-07", false));
                System.out.println(req.getParameter("lastUpdate"));
                
                
                
                return new Organicas<OrganicaMobileEntity>(organicas);
        }


Wouldn't it be easier to make an annotation possible, to change the resource
return method name?


regards,


On Mon, May 30, 2011 at 12:30 PM, Jakub Podlesak-2 [via Jersey] <
ml-node+6418652-938775368-73314_at_n2.nabble.com> wrote:

> Hi Maxrunner,
>
> I am afraid there is a bug in Jersey's JSON POJO mapping feature.
> It currently does not allow the application ContextResolver<ObjectMapper>
> to register different mappers for different types.
> Then if you want to set the root wrapping feature set for certain
> types, and unset for others, you are blocked, unless
> you register the Jackson providers directly.
>
> Let me check how can i fix that in the trunk.
>
> ~Jakub
>
>
> On 05/30/2011 11:54 AM, Maxrunner wrote:
>
> But im using Jackson, anyway im going to post you my contextresolver and
> web.xml configs, plus the classes that give this result. Just give some
> minutes. :)
>
> regards,
>
>
> On Sat, May 28, 2011 at 6:35 PM, Cowtowncoder [via Jersey] <[hidden email]<http://user/SendEmail.jtp?type=node&node=6418441&i=0>
> > wrote:
>
>> On Sat, May 28, 2011 at 2:33 AM, Maxrunner <[hidden email]<http://user/SendEmail.jtp?type=node&node=6414780&i=0>>
>> wrote:
>> > That's what i get unless im doing something wrong...ill try to post the
>> full
>> > code when im back at work. Or ill try to get a run environment here.
>>
>> Ok. It sounds as if maybe there is some configuration that uses one of
>> other json producing methods.
>> I know that some conventions (badgerfish?) use more wrapping around
>> things, mostly since these are needed for XML, and they go through XML
>> api route where some information is missing.
>>
>> -+ Tatu +-
>>
>>
>> ------------------------------
>> If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6414780.html
>> To unsubscribe from how to rename XmlRootElement in JSON, click here.
>>
>
>
> ------------------------------
> View this message in context: Re: how to rename XmlRootElement in JSON<http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6418441.html>
>
> Sent from the Jersey mailing list archive<http://jersey.576304.n2.nabble.com/>at Nabble.com.
>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6418652.html
> To unsubscribe from how to rename XmlRootElement in JSON, click here<http://jersey.576304.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=6173292&code=am9hby5yb3NzYUBnbWFpbC5jb218NjE3MzI5MnwyMDYzODA1MDkw>.
>
>


--
View this message in context: http://jersey.576304.n2.nabble.com/how-to-rename-XmlRootElement-in-JSON-tp6173292p6419105.html
Sent from the Jersey mailing list archive at Nabble.com.