[Simple-support] Unable to properly serialize a list containing nulls
Brought to you by:
niallg
|
From: Shevek <sh...@an...> - 2011-11-29 01:50:34
|
Hi,
public class PersisterFactoryTest {
@Root
public static class Foo {
private List<String> body;
public Foo(@ElementList(name = "body") List<String> body) {
this.body = body;
}
@ElementList(name = "body")
public List<String> getBody() {
return body;
}
}
@Test
public void testNewDeserializer() throws Exception {
List<String> body = new ArrayList<String>();
body.add(null);
body.add("index 1");
body.add(null);
body.add("index 3");
body.add(null);
Persister persister = new Persister();
persister.write(new Foo(body), System.out);
}
}
I get:
<foo>
<body class="java.util.ArrayList">
<string>index 1</string>
<string>index 3</string>
</body>
</foo>
Which deserializes to a different list without the nulls in it.
I like my nulls, they keep me warm on a cold winter's night, and make
sure that my array indices are still correct after deserialization. What
can I do to make them come back, please?
Funnily enough, arrays seem to work OK. Just not lists.
S.
|