I am running a Jersey REST service. The POJO's which represent my resources are JAXB (XML) annotated simple Java classes (they are generated from a schema definition - so they have the annotations).

I want Jersey/Jackson to ignore the XML-Annotations. I did this configuration in my web.xml (as mentioned here):

  <init-param>
    <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
    <param-value>true</param-value>
  </init-param>

I now expected that the @XMLElement annotation would not be used anymore for JSON field naming policy.

But looking at this java field (member)

@XmlElement(name = "person", required = true)
protected List<Person> persons;

I still get the following JSON representation:

....,"person":[{"name":"FooBar", ....... (person without the 's')

All other fields also still get their JSON names from the @XmlElement annotation instead from the Java field name.

I would like to achieve a JSON output as describe in the Jackson Full Data Binding (POJO) Example.

It works fine in simple tests like this (with my XML annotated classes):

  ObjectMapper mapper = new ObjectMapper(); 
  mapper.writeValue(System.out, myObject);

but embedded in Jersey I did not get the expected JSON output.

Are their other configuration options in Jersey to get the 'simple' POJO JSON representation (because this fits best to clients which have to deserialize the JSON result).

Thanks Klaus

Detailed solution

(1) Implement a ContextResolver for Jacksons ObjectMapper which creates

Edit
Report