fix: flatten UUID to str for make_json_safe()
This commit is contained in:
parent
663f438e4e
commit
18484a72ac
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue