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

14 Replies, 1254 Views

Ugh, datetime is the worst with python json.dumps embedded object stuff.

`default=str` is fine for quick fixes, but if you want something cleaner, try `pendulum` or `arrow` for datetime handling. They serialize nicely to strings.

Or, if you’re lazy (like me), just convert everything to dicts first with `vars()` or `.__dict__` before dumping.

Not the *most* elegant, but gets the job done.

Messages In This Thread



Users browsing this thread: 1 Guest(s)