I’m using retrofit and Jackson to deserialaze XML from body.
The third-party Api returns me xml of the form
<Answer>
<Seance Hall="auditorium">
<Hall>
<Sector />
<Sector />
...
</Hall>
</Seance>
</Answer>
As you can see “Hall” apeared twice in XML, as property of Seance and as a nested element. I need to create class for deserialization this XML.
I’ve created class for deserialization:
public class SeanceResponse {
@JacksonXmlProperty(isAttribute = true)
private String hall;
@JacksonXmlProperty(localName = "Hall")
@JacksonXmlText
private HallResponse hallResponse;
}
public class HallResponse {
@JacksonXmlProperty(localName = "Sector")
@JacksonXmlElementWrapper(useWrapping = false)
private List<SectorResponse> sectors = new ArrayList<>();
As you might expect I’m getting an error com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Multiple fields representing property "Hall": SeanceResponse#hall vs SeanceResponse#hallResponse
Is there any way to handle such a case?