Skip to content
Uniform interface to various serializers (e.g.: pickle, json, yaml, phpserialize, etc.)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A uniform interface to a bunch of different ways to serialize data in Python.

There are a plethora of ways to serialize data in Python, but they often have annoyingly different interfaces.

For example:

This makes it a bit annoying when you're writing software and want to be able to let the user specify different serialization formats.

Some frameworks have developed useful abstractions for serialization. For example, Django's serialization framework. But this is unnecessarily tied to the Django framework and the Django ORM. Serialization is a general problem that is not specific to any framework.

Things shouldn't be this way.

>>> anyserializer.serialize('json', {'a': 1, 'b': 2, 'c': {'d': 3, 'e': 4}})
'{"a": 1, "c": {"e": 4, "d": 3}, "b": 2}'
>>> anyserializer.serialize('yaml', {'a': 1, 'b': 2, 'c': {'d': 3, 'e': 4}})
'a: 1\nb: 2\nc: {d: 3, e: 4}\n'
>>> anyserializer.serialize('pickle', {'a': 1, 'b': 2, 'c': {'d': 3, 'e': 4}})
>>> anyserializer.serialize('phpserialize', {'a': 1, 'b': 2, 'c': {'d': 3, 'e': 4}})
>>> anyserializer.serialize('plist', {'a': 1, 'b': 2, 'c': {'d': 3, 'e': 4}})
'<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">\n<plist version="1.0">\n<dict>\n\t<key>a</key>\n\t<integer>1</integer>\n\t<key>b</key>\n\t<integer>2</integer>\n\t<key>c</key>\n\t<dict>\n\t\t<key>d</key>\n\t\t<integer>3</integer>\n\t\t<key>e</key>\n\t\t<integer>4</integer>\n\t</dict>\n</dict>\n</plist>\n'
>>> anyserializer.serialize('biplist', {'a': 1, 'b': 2, 'c': {'d': 3, 'e': 4}})
'bplist00bybiplist1.0\x00\xd3\x01\x02\x03\x04\x05\x06QaQcQb\x10\x01\xd2\x07\x08\t\nQeQd\x10\x04\x10\x03\x10\x02\x15\x1c\x1e "$1)+-/\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x003'
Something went wrong with that request. Please try again.