Search code examples
pythonjsongoogle-app-engineserializationsimplejson

How to use simplejson to serialize and maintain properties?


For a dictionary containing these two key-value pairs:

str = StringProperty
time = DateTimeProperty

I want to serialize it to JSON, store it in the Datastore, and then fetch it, and deserialize it into the original properties.


Solution

  • Try to do it this way:

    d = {
      'str'  : StringProperty,
      'time' : unicode(DateTimeProperty)
    }
    s = simplejson.dumps(d)
    print s