Search code examples
javaxmlxstream

XSTREAM array converter


I want to convert below XML to objects. I

<authentication>
    <name>Reese Rideout</name>
    <shows type="array">
        <show>stage</show>
        <show>youtube</show>
    </shows>
</authentication>

I have Authentication class with List<Show> shows. I believe I will need to use the array converter. However, I do not understand how to use it and am not finding any documents.

Kindly suggest how could I parse this into my object graph.


Solution

  • This is how I fixed this:

    xstream.alias("shows", Shows.class);
    xstream.alias("show", String.class);
    

    And also set the Shows.shows field as an implicit collection: xstream.addImplicitCollection(Shows.class, "shows");