def METHOD_NAME(self, o):
    if isinstance(o, datetime.datetime):
        if o.tzinfo:
            # eg: '2015-09-25T23:14:42.588601+00:00'
            return o.isoformat('T')
        else:
            # No timezone present - assume UTC.
            # eg: '2015-09-25T23:14:42.588601Z'
            return o.isoformat('T') + 'Z'
    if isinstance(o, datetime.date):
        return o.isoformat()
    if isinstance(o, Decimal):
        if o == int(o):
            return int(o)
        return float(o)
    json.JSONEncoder.METHOD_NAME(self, o)