Trying to create a metaclass that inherits from a parent class, that inherits from JSONEncoder. However, I am getting the following error:
TypeError: 'type' object is not iterable
Code looks like:
class ParentClass(JSONEncoder):
def __init__(self, ...):
...
...
def default(self, obj):
try:
return super().default(obj)
except TypeError as exc:
if 'not JSON serializable' in str(exc):
return str(obj)
raise
class AnotherClass():
def __init__(...):
...
def do_something(self, *args. **kwargs):
attrs = {'field1': "FieldOne", 'field2': "FieldTwo"}
ChildClass = type('ChildClass', tuple(ParentClass), attrs)
...
Is there anyway to make this ChildClass
iterable using this method?