3
0
Fork 0

fix: flatten UUID to str for make_json_safe()

This commit is contained in:
Lance Edgar 2024-12-08 18:08:41 -06:00
parent 663f438e4e
commit 18484a72ac

View file

@ -27,6 +27,7 @@ Web Utilities
import importlib
import json
import logging
import uuid as _uuid
import warnings
import sqlalchemy as sa
@ -531,6 +532,10 @@ def make_json_safe(value, key=None, warn=True):
parent[key] = make_json_safe(value, key=key, warn=warn)
value = parent
# convert UUID to str
if isinstance(value, _uuid.UUID):
value = value.hex
# ensure JSON-compatibility, warn if problems
try:
json.dumps(value)