json.dumps({'day': date(2026, 7, 28)}) raises TypeError — dates aren't JSON. Write dump_with_dates(obj) passing a default= function that converts date/datetime values to their isoformat() strings and raises TypeError for anything else unknown.dump_with_dates({'day': date(2026, 7, 28)}){"day": "2026-07-28"}The hook translated the unserializable value.
def encode(o): if isinstance(o, (date, datetime)): return o.isoformat().
Re-raise TypeError otherwise — dumps expects that.