How to handle embedded objects in Python json.dumps? Struggling with serialization! or Best way to se

14 Replies, 1245 Views

lol welcome to the pain club.

Honestly, `default=str` is my go-to for quick scripts, but for prod code, a custom encoder is worth the effort.

Pro tip: if your nested classes are SQLAlchemy models, `marshmallow-sqlalchemy` is a lifesaver.

Otherwise, just recursively dump `__dict__` like others said.

Messages In This Thread



Users browsing this thread: 1 Guest(s)