Skip to content
Advertisement

Python’s cPickle deserialization from PHP?

I have to deserialize a dictionary in PHP that was serialized using cPickle in Python.

In this specific case I probably could just regexp the wanted information, but is there a better way? Any extensions for PHP that would allow me to deserialize more natively the whole dictionary?

Apparently it is serialized in Python like this:

import cPickle as pickle

data = { 'user_id' : 5 }
pickled = pickle.dumps(data)
print pickled

Contents of such serialization cannot be pasted easily to here, because it contains binary data.

Advertisement

Answer

If you want to share data objects between programs written in different languages, it might be easier to serialize/deserialize using something like JSON instead. Most major programming languages have a JSON library.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement