FasterXML / FasterXML/jackson-dataformat-xml

Problem trying to generate XML with dynamic list entry tags

Aperta
#400 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
jaxb-type-id
Lingua principale
Java
Stelle
631
Fork
246
Merge medio
7g 9h
PR unite (30g)
13

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.