Hi I have made a custom JSONEncoder and happened to run into this issue. When I use the dumps function of simplejson the nested object gets serialize as a string. For example I use this:
simplejson.dumps({'lat': obj.lat, 'lon': obj.lon})
And get this:
{
website: "http://something.org",
location: "{"lat": 12.140158037163658, "lon": -86.24754807669069}"
}
If you see location object is with double quotes is there a way I can specify location object to be dump properly as a JSON object (without the double quotes).
Edit
class jsonEncoder(simplejson.JSONEncoder):
def default(self, obj):
isinstance(obj, db.GeoPt):
return simplejson.dumps({'lat': obj.lat, 'lon': obj.lon})
else:
return simplejson.JSONEncoder.default(self, obj)