-
-
Save uncletomiwa/be10759d3b39958c8ce5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import datetime | |
from time import mktime | |
from google.appengine.ext import ndb | |
__author__ = 'oyewale' | |
class GeoDateEncoder(json.JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, datetime.datetime): | |
return int(mktime(obj.timetuple())) | |
elif isinstance(obj, ndb.GeoPt): | |
return {'lat': obj.lat, 'lon': obj.lon} | |
return json.JSONEncoder.default(self, obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment