For my current project I want to serialize some plain old java objects and store them in a database. That’s easy. However, for debugability I would like the serialized data to be human readable, and I figure that there should be plenty of libs that supply drop in replacement functionality for ObjectInputStream/ObjectOutputStream.
Well, it was a bit more difficult than I thought. From my first go at the problem I concluded to myself.
I can’t seem to find an XML serialization framework that works the same way as the plain old java serialization.
1) java.beans.Encoder : requires no-arg constructor, but doesn’t seem to handle collections properly (fails, returns null)
2) XStream : has too many dependencies.
3) Simple : requires annotations, and requires knowing the Class that we want to deserialize to (ugly but workable). Best candidate.
4) Betwixt : requires knowing the Class that we want to deserialize to, fails to handle collections without silly naming conventions or extra code.
5) Castor : requires knowing the Class that we want to deserialize to, not tried yet.
Fortunately I was too fast in my judgement of XStream (and maybe the other libs too?). Anyway, all of the dependencies for XStream are optional. And it has a plesantly simple API. Yay, XStream…









