Nash10
Nash10

Reputation: 51

Configure Jackson to use name property of @XmlRootElement

I have a java bean that uses the JAXB annotation: @XmlRootElement(name="beanName"). Is there a way to configure jackson to use the name property of the @XmlRootElement annotation when deserializing?

Upvotes: 5

Views: 3446

Answers (3)

Baked Inhalf
Baked Inhalf

Reputation: 3735

Yes, like this

@JacksonXmlRootElement(localName = "SOMETHING_ELSE")
public class MyClass
{
}

Upvotes: 0

Brendan
Brendan

Reputation: 743

One thing I've done to make sure that Jackson uses the @XMLRootElement of a class is to set the provider class to be JacksonJaxbJsonProvider (rather than, e.g. JacksonJsonProvider). This can be done in a number of ways, depending on what JAX-RS implementation you are using, and whether the code is client side or server side.

Upvotes: 1

Peter Davis
Peter Davis

Reputation: 781

Looks like this is available in Jackson 1.7:

http://jira.codehaus.org/browse/JACKSON-163

See last comment.

Upvotes: 0

Related Questions