[Sugar-devel] How to serialize objects?

Wade Brainerd wadetb at gmail.com
Tue Mar 17 16:21:43 EDT 2009


Hi Thomas,

Many Sugar activities use simplejson to serialize activity state in
the JSON format.

You can see an example below.  It's done in a way that's backwards
compatible between Python 2.5 & 2.6, since there was a 'json' module
in OLPC distributions of Python 2.5 that was *not* simplejson, whereas
in Python 2.6 simplejson is known as 'json'.

http://git.sugarlabs.org/projects/finance/repos/json/blobs/master/finance.py#line23
http://git.sugarlabs.org/projects/finance/repos/json/blobs/master/finance.py#line656

Regards,
Wade

On Tue, Mar 17, 2009 at 3:21 PM, Behavior Vehikel
<b.vehikel at googlemail.com> wrote:
> Hi,
>
> at the moment I am learning  to implement a Sugar activity. In the
> Sucrose 0.84 release notes
> http://wiki.sugarlabs.org/go/DevelopmentTeam/Release/Releases/Sucrose/0.84#What_is_new_for_developers
> there is a short paragraph about serializing and de-serializing a
> Python object structure.
> Should I use cjson for saving the state of my activity?
> Where can I find sample code?
>
> In a former project (outside of Sugar) I used pickle for object
> serializing and de-serializing. Is better for compatibility to use
> cjson instead of pickle? One advantage of json is its human readable
> output. But why is object serializing not done in XML?
>
> best regards
> Thomas
>
> --
> http://nostalghia.users.sourceforge.net/
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>


More information about the Sugar-devel mailing list