boodebr A little library from boodebr.org


files/feed-icon-14x14.png Recently Edited
ion.api edit
frank, 03 August 2008 (created 03 October 2007)
Tags: ion pickle json xml
Pickling (serializing) data is performed with ionize():
from boodebr.ion import ionize
bytes = ionize(obj, format='json', indent=True, userhooks=None, flatten_only=False):


Where:
obj
Object to pickle (serialize)
format
Format to write, either 'json' or 'xml' (case sensitive).
indent
True|False: Should output be indented ("pretty-formatted")?
userhooks
A list of user-defined hooks. See hooks API.
flatten_only
If True, data will be strictly flattened, with no hooks added to enable reconstruction via deionize(). This may be needed when passing data to some JSON implementations that cannot handle the extra hook attributes.


The return value (bytes) is always a UTF-8 encoded bytestring.

Unpickling (deserializing) is performed with deionize():
from boodebr.ion import deionize
obj = deionize(buf, userhooks=None)


Where:
buf
Normally this is the UTF-8 bytestream returned from ionize, but may be a Unicode value as well.
userhooks
A dictionary of user-defined hooks. See hooks API.


Returns the unpickled object.

blog comments powered by Disqus