Currently working on a quick little project in python and am attempting to encode an object into a JSON string. I've done this several times before without any problem except for now. Usually I just do the following.
def ClassToEncode :
    def __init__(self, arg1, arg2, ..., argn) :
        self.attr1 = arg1
        self.attr2 = arg2
        ...
        self.attrn = argn
     ...
     def toJSON(self) :
         return json.dumps(self, default=lambda o: o.__dict__)
But the problem is that one of my class attributes is a datetime.datetime object and I am being thrown the following error
AttributeError: 'datetime.datetime' object has no attribute '__dict__'
Any thoughts or wraparounds that could enable the functionality of including the datetime attribute into the JSON output??
Thanks in advance!
 
     
     
    