I am receiving notifications in xml format from a third party system and trying to parse them with XStream.
Notification sent from third party system looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<account>
<phone1>unknown</account_code>
<phone2/>
<phone3 nil="true"/>
</account>
An our java representation of the notification looks like this:
public class Account {
private String phone1;
private String phone2;
private String phone3;
}
Out of the box XStream parses phone1 and phone2 as expected, but phone3 is of course also parsed to an empty string.
Is there a neat way to make XStream understand that when nil="true" that the value should be set to null?