-
-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Description
Used version:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.12.2</version>
</dependency>
I'm still observing the same behaviour as in #124 At least with that version it is alwas one null element. With others it varies on class nesting.
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY, getterVisibility=JsonAutoDetect.Visibility.NONE,
setterVisibility=JsonAutoDetect.Visibility.NONE, creatorVisibility=JsonAutoDetect.Visibility.NONE)
@JsonIgnoreProperties(ignoreUnknown = true)
public class StreamingProxyChannel {
@JacksonXmlProperty(localName = "streamingProxyChannelId")
private String streamingProxyChannelId;
public String getStreamingProxyChannelId() {
return streamingProxyChannelId;
}
public void setStreamingProxyChannelId(String streamingProxyChannelId) {
this.streamingProxyChannelId = streamingProxyChannelId;
}
}
@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY, getterVisibility=JsonAutoDetect.Visibility.NONE,
setterVisibility=JsonAutoDetect.Visibility.NONE, creatorVisibility=JsonAutoDetect.Visibility.NONE)
@JacksonXmlRootElement(localName = "InputProxyChannelStatus")
@JsonIgnoreProperties(ignoreUnknown = true)
public class InputProxyChannelStatus {
@JacksonXmlProperty(localName = "id")
private String id;
@JacksonXmlProperty(localName = "streamingProxyChannelIdList")
@JacksonXmlElementWrapper(useWrapping = false)
private List<StreamingProxyChannel> streamingProxyChannelIdList;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<StreamingProxyChannel> getStreamingProxyChannelIdList() {
return streamingProxyChannelIdList;
}
public void setStreamingProxyChannelIdList(List<StreamingProxyChannel> streamingProxyChannelIdList) {
this.streamingProxyChannelIdList = streamingProxyChannelIdList;
}
}
public class ModelTest {
private final static XmlMapper xmlMapper = new XmlMapper();
@Test
public void inputProxyChannelStatusTest() throws IOException {
String input = "<InputProxyChannelStatus>\n" +
"<id>2</id>\n" +
"<streamingProxyChannelIdList>\n" +
"</streamingProxyChannelIdList>\n" +
"</InputProxyChannelStatus>";
InputProxyChannelStatus inputProxyChannelStatus = xmlMapper.readValue(input, InputProxyChannelStatus.class);
Assert.assertEquals("List should be empty", 0, inputProxyChannelStatus.getStreamingProxyChannelIdList().size());
}
}
Metadata
Metadata
Assignees
Labels
No labels