I have wrapper class:
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Wrapper {
private String id;
private int number;
private Element inte
You have two options:
internal
type to Document
or Node
.Element element = document.getDocumentElement()
;Custom deserialiser:
class ElementDeserializer extends DOMDeserializer<Element> {
private static final long serialVersionUID = 1L;
public ElementDeserializer() {
super(Element.class);
}
@Override
public Element _deserialize(String value, DeserializationContext ctxt)
throws IllegalArgumentException {
return parse(value).getDocumentElement();
}
}
You can register it as below:
SimpleModule elementModule = new SimpleModule();
elementModule.addDeserializer(Element.class, new ElementDeserializer());
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(elementModule);
But I suggest to stay with custom deserialisers for Documen
- com.fasterxml.jackson.databind.ext.DOMDeserializer.DocumentDeserializer
and Node
- com.fasterxml.jackson.databind.ext.DOMDeserializer.NodeDeserializer
.