json dumps datetime

def myconverter(o):
    if isinstance(o, datetime.datetime):
        return o.__str__()

print(json.dumps(d, default = myconverter))

Here is what the above code is Doing:
1. We are defining a function myconverter() which takes a single parameter o.
2. We are checking if the parameter o is an instance of datetime.datetime.
3. If it is, we are returning the string representation of the datetime object.
4. We are passing the function myconverter() as the default parameter to the json.dumps() function.
5. The json.dumps() function will call the myconverter() function for each datetime object found in the dictionary.
6. The myconverter() function will return the string representation of the datetime object.
7. The json.dumps() function will serialize the string representation into JSON format.