FasterXML / FasterXML/jackson-modules-base

jackson-module-jaxb-annotations: can't use both @XmlElementWrapper and @XmlElement

Open
#213 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
180
Forks
80
Avg merge
3h 26m
Merged PRs (30d)
1

Description

Migrating an application from resteasy-jettison-provider to resteasy-jackson2-provider, but need to retain the JSON format. Can't configure JaxbAnnotationIntrospector to properly handle the case of `@XmlElementWrapper` + `@XmlElement `together. Depending on MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, it either uses one or the other, but not both. Jettison's default behavior is to use both.

**Example:**

```
@XmlRootElement(name = "Parent")
public class Parent {

private List children = new LinkedList<>();

@XmlElementWrapper(name = "Children")
@XmlElement(name = "Child")
public List getChildren() {
return children;
}

public void setChildren(List children) {
this.children = children;
}
}
```

Using Jettison:
```
{"Parent":{"Children":{"Child":[{"Value":1},{"Value":2}]}}}
```

Using JaxbAnnotationIntrospector with MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME enabled:
```
{"Parent":{"Children":[{"Value":"1"},{"Value":"2"}]}}
```

Using JaxbAnnotationIntrospector with MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME disabled:
```
{"Parent":{"Child":[{"Value":"1"},{"Value":"2"}]}}
```

**Test:**
https://bitbucket.org/alexlitovsky1/jaxb-annotations-bug/

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.