Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

How to convert typesystem to JSON? #152

Description

@TC-THREE

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)
class Mall(BaseDatabase)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions