This file contains hidden or 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
class JSONEncoder(json.JSONEncoder): | |
"""JSONEncoder that handles decimal and time types. | |
""" | |
def default(self, o): | |
if isinstance(o, decimal.Decimal): | |
return float(o) | |
elif hasattr(o, 'isoformat'): | |
return o.isoformat() | |
return super(DecimalEncoder, self).default(o) |