[Simple-support] Serializing/ deserializing List<Object> containing objects of different types
Brought to you by:
niallg
|
From: Stanislaw O. <sta...@ca...> - 2008-02-09 16:29:32
|
Hello,
First of all, thanks for the great piece of software, it simplifies things a
lot!
I'm not yet an advanced user of Simple XML, hence a possibly silly question.
The following code:
@Root
public class SimpleTest
{
@ElementList
private List<Object> test = new ArrayList<Object>();
public static void main(String [] args) throws Exception
{
SimpleTest test = new SimpleTest();
test.test.add(10);
test.test.add(0.5);
test.test.add("string");
Persister persister = new Persister();
persister.write(test, System.out);
}
}
produces something like this on output:
<simpleTest>
<test class="java.util.ArrayList">
<object class="java.lang.Integer"/>
<object class="java.lang.Double"/>
<object class="java.lang.String"/>
</test>
</simpleTest>
Clearly, the information on output is incomplete to deserialize the object
successfully.
Question: can I (how?) serialize/ deserialize Lists and Maps containing
objects of different types as values?
Cheers,
Staszek
|