craftbeerpi4-pione/core/utils/encoder.py
2019-01-02 21:20:44 +01:00

23 lines
595 B
Python

from json import JSONEncoder
class ComplexEncoder(JSONEncoder):
def default(self, obj):
from core.database.orm_framework import DBModel
try:
if isinstance(obj, DBModel):
return obj.__dict__
#elif callable(getattr(obj, "reprJSON")):
# return obj.reprJSON()
#elif isinstance(obj, ActorModel):
# return None
#elif hasattr(obj, "callback"):
# return obj()
else:
return None
except TypeError:
pass
return None