Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XStream-like XML serialization for Jython objects?

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?

like image 392
Joonas Pulakka Avatar asked Dec 30 '25 14:12

Joonas Pulakka


1 Answers

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.

like image 105
Joonas Pulakka Avatar answered Jan 02 '26 04:01

Joonas Pulakka