views:

139

answers:

1

Jython is great for creating custom data structures on need basis, but how to store their instances? Apparently it's possible to do it via java.io.Serializable, but ObjectStreams are not human readable; I would prefer XML.

I naïvely tried XStream to serialize a simple object created in Jython and translated to Java with PyObject's __tojava__ method, but the result was, expectedly, pretty much gibberish because of XStream's heavy use of reflection (it finds all Jython's internals) - and deserialization doesn't work (maybe because of Jython's dynamically loaded proxy classes or some other implementation details that I'm really not familiar with.)

Is there anything like XStream for Jython objects - perhaps a Jython library?

+2  A: 

Apparently Jython is not that ideal for on need data structure creation although it's great for custom data processing. I ended up using DynaBeans from Apache BeanUtils to create the data structures. They play with XStream and Jython just fine.

Joonas Pulakka