Serializing a Python object to/from a S60 phone
-
21-08-2019 - |
Question
I'm looking for a way to serialize generic Python objects between a CherryPy-based server and a Python client running on a Symbian phone.. Since pyS60 doesn't implement the pickle module, how would you do it?
I know about Cerealizer but it requires you to register classes before use (which I'd like to avoid) and doesn't look very mature.. So, what would you use? Python 2.2's pickle module maybe, extracted from the sources? XML, JSON? Which one of the several libraries? :)
Solution
What's wrong with using the pickle module?
OTHER TIPS
There is a json module someone wrote for PyS60. I'd simply grab that, serialize things into json and use that as the transfer method between the web/client app.
For the json lib and a decent book on PyS60: http://www.mobilepythonbook.org/
The last versions of Python (>1.9) have the module pickle and cPickle are available
Another alternative to JSON serialization is to use the netstring (look on wikipedia) format to serialize. It's actually more effective than JSON for binary objects.
You can find a good netstring module here http://github.com/tuulos/aino/blob/d78c92985ff1d701ddf99c3445b97f452d4f7fe2/wp/node/netstring.py (or aino/wp/node/netstring.py)