A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearUnserialize in Java a serialized php object - page 1
User InfoPosts
Unserialize in Java a serialized php object#1
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?


posted date: 2009-04-13 01:03:00

Re: Unserialize in Java a serialized php object#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-13 01:03:01

Re: Unserialize in Java a serialized php object#3
Theoretically, it(s certainly possible. It(s just bytes after all, and they can be parsed. Of course, the deserialized object would contain only data, not any of the PHP methods. If you want that, you(d have to rewrite the behaviour as Java classes that correspond directly with the PHP classes. In practice, the main problem seems to be that the PHP serialization format does not seem to be formally specified - at least there is no link to a specification in the manual.So you might have to dig through the code to understand the format.All in all, it sounds like it would be much easier and more stable to use something like XML serialization - I(m sure both languages have libraries that faciliate this.

posted date: 2009-04-13 01:16:00

Re: Unserialize in Java a serialized php object#4
Note that there(s a Java implementation of PHP. So you may be able to serialise the object and pass it to your Java-PHP instance, deserialise and then call into your Java infrastructure.It all sounds a bit of an unholy mess, but perhaps worth looking at!

posted date: 2009-04-13 01:21:00

Re: Unserialize in Java a serialized php object#5
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.

posted date: 2009-04-13 01:24:00

Re: Unserialize in Java a serialized php object#6
Try xstream (converts Java objects into readable XML) to serialize and then write your own PHP code to deserialize.

posted date: 2009-04-13 03:37:00

Re: Unserialize in Java a serialized php object#7
Use Web Services (REST, RPC, SOAP) or any other solution storing plain text that will allow you to read/rebuild the data from Java.

posted date: 2009-04-13 04:07:00

Re: Unserialize in Java a serialized php object#8
I remember a snippet for Drupal (PHP CMS) where this functionality was needed. Just found it, so take a look at Serialized drupal node objects to java (should work with any PHP serialized object).Maybe you can use that. I don(t know whether there are issues with newer versions of PHP.

posted date: 2009-04-13 04:19:00

Re: Unserialize in Java a serialized php object#9
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.

posted date: 2009-04-13 04:32:00

Re: Unserialize in Java a serialized php object#10
Serializing an object in PHP will dump the object properties. The resulting string isn(t terribly complicated.echo serialize(array(1, null, "mystring", array("key"=>"value")));Results in:a:4:{i:0;i:1;i:1;N;i:2;s:8:"mystring";i:3;a:1:{s:3:"key";s:5:"value";}}The string identifies datatypes, array lengths, array indexes and values, string lengths... Wouldn(t take too much effort to reverse-engineer it and come up with your own parser, I think.

posted date: 2009-04-13 04:39:00

Re: Unserialize in Java a serialized php object#11
Sure, but it works well to transfer primitive types and is supported well by most languages.

posted date: 2009-04-13 06:14:00

Re: Unserialize in Java a serialized php object#12
json.org lists 35 languanges that have implementations so I would say its not meant exclusively for Javascript.

posted date: 2009-04-13 06:20:00

select page: « 1 2 »
Copyright ©2008-2017 www.momige.com, all rights reserved.