[Simple-support] erialize/deserialize Lists with empty Strings
Brought to you by:
niallg
|
From: Joe <fis...@ya...> - 2008-12-16 13:55:47
|
Hi,
The following code prints:
values: [A, null]
Why null and not an empty String?
How can serialize/deserialize Lists with empty Strings?
thx
public class TestData
{
@ElementList(name = "values", required = false)
private List<String> _values = new ArrayList<String>();
TestData()
{
_values.add("A");
_values.add("");
}
List<String> getValues()
{
return _values;
}
public static void main(String[] args) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
serializer.write(new TestData(), xmlFile);
TestData sqlData = serializer.read(TestData.class, xmlFile);
System.out.println("values: " + sqlData.getValues());
}
}
|