I'm using XStream parser. I wants to get an empty tag in place of null values for a variable. How do I achieve this?
Example:
class Person{
private String name;
private String age;
}
Person person = new Person("Joe", null);
I'm getting this,
<Person>
<name>Joe</name>
</Person>
I need this,
<Person>
<name>Joe</name>
<age></age>
</Person>
If it only concerns strings, initialise them with "", not with null.
So instead of:
Try:
Also, make sure to take a look at: XStream serialize null values