This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/teal/json_util.py

12 lines
390 B
Python
Raw Permalink Normal View History

2023-03-21 16:31:43 +00:00
import ereuse_devicehub.ereuse_utils
2023-03-21 11:08:13 +00:00
from flask.json import JSONEncoder as FlaskJSONEncoder
from sqlalchemy.ext.baked import Result
from sqlalchemy.orm import Query
2023-03-21 16:31:43 +00:00
class TealJSONEncoder(ereuse_devicehub.ereuse_utils.JSONEncoder, FlaskJSONEncoder):
2023-03-21 11:08:13 +00:00
def default(self, obj):
if isinstance(obj, (Result, Query)):
return tuple(obj)
return super().default(obj)