K
K
kidar22016-05-23 12:30:11
Java
kidar2, 2016-05-23 12:30:11

How to parse an xml element into a primitive type?

There is this xml:

<order>
    <id_address_delivery>4</id_address_delivery>
<order>

And such a java class:
@JacksonXmlRootElement(localName = "order")
public static class Order
{
    @JacksonXmlProperty(localName = "id_address_delivery")
    public String id_address_delivery;
}

I'm trying to parse with jackson:
XmlMapper XmlMapper = new XmlMapper()
XmlMapper.readValue(xml, cls);

I get the error Can not deserialize instance of java.lang.String out of START_OBJECT token
Can't find an option to treat certain tags as primitive types.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question