如何序列化Java对象,使其可以被pickle(Python)反序列化? [英] How do I serialize a Java object such that it can be deserialized by pickle (Python)?

查看:680
本文介绍了如何序列化Java对象,使其可以被pickle(Python)反序列化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python服务,该服务使用pickle消息作为其协议的一部分。我想从Java查询此服务,但为此,我需要在客户端(Java)上发布我的消息。是否有在JVM上运行的 pickle 的任何实现(理想情况下具有最小的依赖性)?

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.

推荐答案

另外的调查产生了 pyrolite ,这是一个MIT许可的库,允许Java和.NET程序与Python连接世界。除了远程对象功能外,它(更重要的是)还包括一个 pickle 序列化器和反序列化器。

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.

这篇关于如何序列化Java对象,使其可以被pickle(Python)反序列化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆