FasterXML / FasterXML/jackson-modules-base

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

オープン
#213 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
180
フォーク
80
平均マージ
3時間 26分
マージ済み PR(30日)
1

説明

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/

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。