I'm building a fairly large JSON dictionary where I specify a few uuids like this:
import uuid
game['uuid'] = uuid.uuid1()
I'm getting a type error with the following traceback. I'm not sure what the issue is because we can have UUIDs within json objects
Traceback (most recent call last):
File "/Users/claycrosby/Desktop/coding/projects/gambling/scraper/sbtesting.py", line 182, in <module>
game_json = json.dumps(game)
File "/opt/miniconda3/envs/ds383/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/opt/miniconda3/envs/ds383/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/opt/miniconda3/envs/ds383/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/opt/miniconda3/envs/ds383/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type UUID is not JSON serializable
[Finished in 0.5s with exit code 1]
[cmd: ['/opt/miniconda3/envs/ds383/bin/python3', '/Users/claycrosby/Desktop/coding/projects/gambling/scraper/sbtesting.py']]
[dir: /Users/claycrosby/Desktop/coding/projects/gambling/scraper]
[path: /opt/miniconda3/bin:/opt/miniconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/Users/claycrosby/Desktop/coding/programs/pbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin]