Skip to content

Instantly share code, notes, and snippets.

@nicc777
Created October 28, 2022 07:03
Show Gist options
  • Save nicc777/c17cd3be6ff327a314912691be5db8cf to your computer and use it in GitHub Desktop.
Save nicc777/c17cd3be6ff327a314912691be5db8cf to your computer and use it in GitHub Desktop.
Dumping dicts to json in Python, where the dict has `datetime` or `tzlocal` objets
import json
import datetime
from dateutil.tz import tzlocal # pip3 install python-dateutil
your_dict = {} # Data...
json.dumps(your_dict, sort_keys=True, default=str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment