Unserialize in Java a serialized php object

2020-01-26 10:31发布

Does anyone know if it is possible, actually if it has been done, to serialize an object in php and unserialize it in Java (java-php communication). Maybe an adapter will be needed.

What do you think?

Thanks

15条回答
对你真心纯属浪费
2楼-- · 2020-01-26 11:16

PHP and Java both use their own (obviously different) serialization schemes. You could however use an interchange format both could read and write.

The two most obvious examples are XML and JSON.

There are others however such as Google Protocol Buffers.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2020-01-26 11:17

The JSON format would be a good place to start. There are implementations for Java, PHP and many other languages.

While initially based on the javascript object literal notation, JSON proved convenient for lightweight data transfer between all types of systems.

查看更多
▲ chillily
4楼-- · 2020-01-26 11:18

Try xstream (converts Java objects into readable XML) to serialize and then write your own PHP code to deserialize.

查看更多
登录 后发表回答