I have a class Submission
(shown below) which has a list called return of type Return. When I deserialize the object the Return
element twice. Is there a way for the return element to only occur once?
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ReturnType", propOrder = {
"t619",
"_return"
})
@XmlRootElement(name = "Submission")
public class Submission {
@XmlElement(name = "Return", required = true)
protected List<Return> _return;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ReturnChoiceType", propOrder = {
"t4",
"t4A",
...
})
public class Return {
@XmlElement(name = "T4")
protected T4ReturnType t4;
...
}
Generated XML
<Return> <!-- One return -->
<Return> <!-- Another return -->
<T4>
</T4>
</Return>
</Return>
Because, Return
element contains List
of Return
object.
@XmlElement(name = "Return", required = true)
protected List<Return> _return;
You need to change List<Return>
to List<String>
protected List<String> _return;
As you haven't shared complete details of Return
class, but I'm assuming you may need to change something there as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.