def default(self, obj): if isinstance(obj, Type): return obj.serialize() return json.JSONEncoder.default(self, obj)