Код: Выделить всё
from dataclasses import dataclass
@dataclass
class Foo:
x: str
Код: Выделить всё
>>> import json
>>> foo = Foo(x="bar")
>>> json.dumps(foo)
TypeError: Object of type Foo is not JSON serializable
Подробнее здесь: https://stackoverflow.com/questions/512 ... ataclasses