-
-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Description
when I try to parse the following XML I get an error with Jackson:
<root>
<aCollection>
<language xml:lang="en">
<entry id="1" value="foo"/>
<entry id="2" value="bar"/>
<entry id="3" value="blah"/>
</language>
</aCollection>
</root>
The classes I use are:
@Data
@JacksonXmlRootElement(localName = "root")
public class RootDTO {
@JacksonXmlProperty(localName = "aCollection")
private CollectionDTO collection;
}
@Data
public class CollectionDTO {
@JacksonXmlProperty(localName = "language")
LanguageDTO language;
}
@Data
public class LanguageDTO {
@JacksonXmlProperty(localName = "entry")
EntryDTO[] entries;
}
@Data
public class EntryDTO {
@JacksonXmlProperty(isAttribute = true)
private String id;
@JacksonXmlProperty(isAttribute = true)
private String value;
}
The error is:
Can not instantiate value of type [simple type, class com.tinkerdesk.viewer.model.DTO.EntryDTO] from JSON String; no single-String constructor/factory method
If I remove the array brackets it works but of course only parses the first entry element. I found that I should maybe use @JacksonXmlElementWrapper(useWrapping = false) on top of EntryDTO[] entries; since the elements are not wrapped. However this does not comile for me because there is no useWrapping in the com.fasterxml.jackson.xml.annotate.JacksonXmlElementWrapper. My Jackson core version is 2.9.6 and xml-databind 0.6.2. Is there now a newer way to do this?
Metadata
Metadata
Assignees
Labels
No labels