Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def default(self, obj):
- try:
- if isinstance(obj, datetime):
- if obj.utcoffset() is not None:
- obj = obj - obj.utcoffset()
- millis = int(
- calendar.timegm(obj.timetuple()) * 1000 +
- obj.microsecond / 1000
- )
- return millis
- iterable = iter(obj)
- except TypeError:
- pass
- else:
- return list(iterable)
- return JSONEncoder.default(self, obj)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement