FasterXML / FasterXML/jackson-dataformat-xml
Problem trying to generate XML with dynamic list entry tags
- Dominant language
- Java
- Stars
- 631
- Forks
- 246
- Avg merge
- 7d 9h
- Merged PRs (30d)
- 13
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.