Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I parse a PHP serialized datastructure in Java?

I have a system that combines the best and worst of Java and PHP. I am trying to migrate a component that was once written in PHP into a Java One.

Does anyone have some tips for how I can parse a PHP serialized datastructure in Java? By serialized I mean output from php's serialize function.

like image 953
Allain Lalonde Avatar asked Sep 18 '08 23:09

Allain Lalonde


2 Answers

PHP serializes to a simple text-based format. PHPSerialize looks like a parser written in Java. You can also port the Python implementation to Java -- I doubt it's very complex.

like image 134
John Millikin Avatar answered Sep 19 '22 13:09

John Millikin


I had the same issue and found this library: http://code.google.com/p/serialized-php-parser/

It does exactly what you need

like image 25
LiorH Avatar answered Sep 16 '22 13:09

LiorH