Hi Maxrunner, just a small comment in-line...
On 05/30/2011 08:33 PM, Maxrunner wrote:
> *"I have mentioned this multiple times, but wrapping only applies to the
> actual type of the value. In this case it is the List type; and
> annotation thereby MUST BE for that type.
> Whatever types of values within List have is irrelevant and will not
> be used under any circumstances. "*
>
> If you're using a list wrapper class then the name of the variable
> containing the list is the one used. But then it also adds the wrapper
> class itself.
>
> *"(a) Add @XmlRootElement annotation to relevant List type; either by *
> *sub-classing as a new class with annotation; or by using mix-in
> annotations to associate annotation. "*
>
> The fix jakub is doing seems to be the more straightforward option.
My fix only ensures, you get the right object mapper in place.
That is what Tatu means with: "as long as correct ObjectMapper is being
used".
For everything else you need to rely on Jackson and Tatu's suggestions.
~Jakub
P.S.The fixed version is now available in the maven repository.
> That way i can hide the root element according to the object mapper.
> Dont you agree?, i dont really understand how to use mix in
> annotations, the jackson documentation isnt really that explicit,
>
> *"(b) Implement custom AnnotationIntrospector (extending either
> JacksonAnnotationIntrospector or JaxbAnnotationIntrospector) and
> override 'findRootName' method; in this case you are free to use
> whatever logic you want to associate wrapper name. "*
>
> where do i do this?in the context resolver class?
>
> regards,
>
> On Mon, May 30, 2011 at 7:14 PM, Cowtowncoder [via Jersey] <[hidden
> email] </user/SendEmail.jtp?type=node&node=6420153&i=0>> wrote:
>
> On Mon, May 30, 2011 at 6:24 AM, Maxrunner <[hidden email]
> <http://user/SendEmail.jtp?type=node&node=6420107&i=0>> wrote:
> > 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:
>
> I have mentioned this multiple times, but wrapping only applies to
> the
> actual type of the value. In this case it is the List type; and
> annotation thereby MUST BE for that type.
> Whatever types of values within List have is irrelevant and will not
> be used under any circumstances.
>
> To get wrapping you want, you have couple of choices:
>
> (a) Add @XmlRootElement annotation to relevant List type; either by
> sub-classing as a new class with annotation; or by using mix-in
> annotations to associate annotation.
> (b) Implement custom AnnotationIntrospector (extending either
> JacksonAnnotationIntrospector or JaxbAnnotationIntrospector) and
> override 'findRootName' method; in this case you are free to use
> whatever logic you want to associate wrapper name.
>
> I suggest you try out one of these approaches as they would solve
> your
> problem, as long as correct ObjectMapper is being used.
>
> -+ 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-tp6173292p6420107.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-tp6173292p6420153.html>
> Sent from the Jersey mailing list archive
> <http://jersey.576304.n2.nabble.com/> at Nabble.com.