i need convert typesystem to json, but there is no way to find to_json
iused:
class BaseDatabase(orm.Model):
fields = {}
def __iter__(self):
return self.__next__()
def __next__(self):
for k in self.fields.keys():
if hasattr(self, k):
yield (k, getattr(self, k))
class Json(js.JSONEncoder):
def default(self, o):
if isinstance(o, BaseDatabase):
tmp = dict(o)
if len(tmp.keys()) == 1 and "id" in tmp.keys(): # ForeignKey
return tmp['id']
return tmp
return super().default(o)
i need convert typesystem to json, but there is no way to find to_json
iused: