First, this list is not appropriate. You should ask such a question in python-list.

Second, JSON is a specific serialization format that explicitly rejects datetime objects in *all* the languages with JSON libraries. You can only use date objects in JSON if you control or understand both serialization and deserialization ends and have an agreed representation.

On Fri, Nov 2, 2018 at 12:20 PM Philip Martin <> wrote:
Is there any reason why date, datetime, and UUID objects automatically serialize to default strings using the csv module, but json.dumps throws an error as a default? i.e.

import csv
import json
import io
from datetime import date

stream = io.StringIO()
writer = csv.writer(stream)
writer.writerow([date(2018, 11, 2)])
# versus
json.dumps(date(2018, 11, 2))

Python-ideas mailing list
Code of Conduct: