[Simple-support] Serializing collections with both SimpleXML-annotated and not annotated types
Brought to you by:
niallg
|
From: Stanislaw O. <sta...@ca...> - 2008-09-25 22:51:45
|
Hi there, First of all, thanks for sharing SimpleXML with the world, it makes working with XMLs a breeze! One usage scenario in my code is this: I have a map of objects (Map<String, Object>) that can contain instances of a number of JDK types (String, Integer, Double, Boolean etc.) but also some SimpleXML-annotated types. The problem obviously is that while the annotated types serialize / deserialize nicely, the JDK ones will not (unless the collection has the JDK type in its declaration, which is not possible in my case). I was wondering what was the recommended way of serializing / deserializing such collections. One approach that crossed my mind is replacing the JDK types with some sort of XML-annotated wrappers before serialization and reverting the mapping after deserialization, but maybe there is a better way? (after all, SimpleXML has mechanisms for serialization of e.g. a List<Integer>, so why not reuse them if possible?) Thanks, Staszek -- http://www.carrot2.org |