JSON serialization of Google App Engine models

后端 未结 14 2109
不知归路
不知归路 2020-12-04 04:59

I\'ve been searching for quite a while with no success. My project isn\'t using Django, is there a simple way to serialize App Engine models (google.appengine.ext.db.Model)

14条回答
  •  旧巷少年郎
    2020-12-04 05:45

    You don't need to write your own "parser" (a parser would presumably turn JSON into a Python object), but you can still serialize your Python object yourself.

    Using simplejson:

    import simplejson as json
    serialized = json.dumps({
        'filename': self.filename,
        'title': self.title,
        'date_taken': date_taken.isoformat(),
        # etc.
    })
    

提交回复
热议问题