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 importlib
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import uuid as _uuid
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import sqlalchemy as sa
|
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)
|
parent[key] = make_json_safe(value, key=key, warn=warn)
|
||||||
value = parent
|
value = parent
|
||||||
|
|
||||||
|
# convert UUID to str
|
||||||
|
if isinstance(value, _uuid.UUID):
|
||||||
|
value = value.hex
|
||||||
|
|
||||||
# ensure JSON-compatibility, warn if problems
|
# ensure JSON-compatibility, warn if problems
|
||||||
try:
|
try:
|
||||||
json.dumps(value)
|
json.dumps(value)
|
||||||
|
|
Loading…
Reference in a new issue