Created
October 28, 2022 07:03
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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