On Wed, Jan 2, 2019 at 8:39 AM <915702...@qq.com> wrote:

> i have a xml string like this:
> <a>
>    <b>123</b>
>   <b>456</b>
> </a>
>
> how to i got List<string> a or more  generally List<Object> if the <b>
> element has child element?
>
>
>
The general way to figure out how (and if -- Jackson does NOT guarantee it
can deserialize all valid XML) binding works is to try to do the reverse;
that is, create POJO that will serialize with structure you want to
deserialize. Guarantee is that Jackson should be able to read what it can
write.

In this case you will need to use "unwrapped" Lists, so something like:

@JacksonXmlRootElement(localName = "a")
public class ListWrapper {
   @JacksonXmlElementWrapper(useWrapping = false) // or set global default
   public List<String> b;
}

although `List` and arrays generally work better with POJO-valued elements,
not primitives.

-+ Tatu +-

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to