FasterXML / FasterXML/jackson-dataformat-xml
Problem trying to generate XML with dynamic list entry tags
- 主要言語
- Java
- スター
- 631
- フォーク
- 246
- 平均マージ
- 7日 9時間
- マージ済み PR(30日)
- 13
説明
I am trying to generate a XML payload for an API that uses a XML based query language. I have something similar to the following code:
```java
public class JacksonTest
{
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
@JsonSubTypes({
@JsonSubTypes.Type(value = And.class, name = "and"),
@JsonSubTypes.Type(value = Or.class, name = "or"),
@JsonSubTypes.Type(value = EqualTo.class, name = "equalto"),
})
public interface Filter {
}
public static class And implements Filter {
@JacksonXmlElementWrapper(useWrapping = false)
protected List filter;
}
public static class Or implements Filter {
@JacksonXmlElementWrapper(useWrapping = false)
protected List filter;
}
public static class EqualTo implements Filter {
protected String field;
protected String value;
}
@JacksonXmlRootElement(localName = "query")
public static class MyQuery {
@JacksonXmlElementWrapper(useWrapping = false)
protected List filter;
}
public static void main(String[] args) {
MyQuery myQuery = new MyQuery();
myQuery.filter = new ArrayList<>();
EqualTo equalTo = new EqualTo();
equalTo.field = "WHENMODIFIED";
equalTo.value = "05/14/2020 17:09:33";
And and = new And();
and.filter = new ArrayList<>();
and.filter.add(equalTo);
myQuery.filter.add(and);
}
}
```
and the payload I need would be:
```xml
WHENMODIFIED
05/14/2020 17:09:33
```
but the payload I currently get is:
```xml
WHENMODIFIED
05/14/2020 17:09:33
```
I've already looked everywhere but couldn't figure out how I can convince my And entity to skip the `filter` tag.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。