How to make a XStream tag Optional using annotations

Midswhisara

New Member
How do I make an @XStreamImplicit annotated tag \[code\]Optional\[/code\]. I have 2 classes :Class2 object is declared in Class1\[code\]@XStreamAlias("root")public class Class1 { @XStreamAlias("tag1") private String data1; @XStreamAlias("class2") private Class2 data2;}@XStreamAlias("class2")public class Class2 { @XStreamAlias("tag2child1") private String dataInChild1; @XStreamAlias("tag2child2") private String dataInChild2;}\[/code\]The Xml looks like this \[code\]<root> <tag1>data</tag1> <class2> <tag2child1>dataInChild1</tag2child1> <tag2child2>dataInChild2</tag2child2> </class2></root>\[/code\]If the tag \[code\]<class2>\[/code\] is not present in the xml, its fine.But if its present in the xml, i'll take the data.
 
Back
Top