Why does json.dumps sometimes fail to serialize my Python object? or How can I customize the output f

20 Replies, 1187 Views

lol yeah json.dumps is picky af.

If you don’t wanna write a full encoder, just override `__str__` or `__repr__` in your class to return something json-friendly. Then do `json.dumps(str(your_obj))`.

Not elegant, but hey, it’s a debug dump—who cares?

Messages In This Thread



Users browsing this thread: 1 Guest(s)