Object of type timestamp is not JSON serializable

First of all, the reason for the error is the datetime type field when exporting JSON.

Added in the code:
class dateencoder (JSON. Jsoneencoder):
Default (self, obj):
if isinstance (obj, datetime. Datetime):
return obj.strftime (“% Y -% m -% DT% H:% m:% s”)
else:
return json.jsoneencoder.default (self, obj)

Then add a CLS = dateencoder
in json.dump to solve the problem

As shown in the figure:


no error will be reported

Read More: