I'm using a Python service that uses pickled messages as part of its protocol. I'd like to query this service from Java, but to do so, I need to pickle my message on the client (Java). Are there any implementations of pickle
that run on the JVM (ideally with minimal dependencies)?
Clarification: Modifying the server side is not an option, so while alternate serializations would be convenient, they won't solve the problem here.
To make a Java object serializable we implement the java. io. Serializable interface. The ObjectOutputStream class contains writeObject() method for serializing an Object.
To serialize an object hierarchy, you simply call the dumps() function. Similarly, to de-serialize a data stream, you call the loads() function.
Some additional investigation yielded pyrolite, an MIT-licensed library that allows Java and .NET programs to interface with the Python world. In addition to remote object functionality, it (more importantly) includes a pickle
serializer and de-serializer.
You can use a Java JSON serializer like GSON or Jackson to serilaise quite easily and use a python json pickle to deserialize
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With