How To Json Encode Entities?
Solution 1:
In App Engine Python you can use this script to encode db.Models to JSON. You may have to customize some parts, like the DateTime formatting.
http://code.google.com/p/google-app-engine-samples/source/browse/trunk/geochat/json.py?r=55
Solution 2:
You can't use simplejson.dumps() on a list of db.Model items directly.
See my answer for extending db.Model with some handy methods for serialising db.Model instances
Solution 3:
I use gson for GAE/J. You can give it an object (or in your case, extract stuff from a result-set) and get a JSON string.
Solution 4:
Check the error log for the app engine. It will tell you what error it is experiencing. Probably you are trying to encode a Python type that json it not familiar with. JSON will only do simple stuff like lists and dictionaries. You can't use it for complex, custom types.
Post a Comment for "How To Json Encode Entities?"