Anyone else running into issues with json.dumps hs? How are you handling it? or What’s the best way t

20 Replies, 1184 Views

Silent fails with json.dumps hs drove me nuts too!

Turns out, it was NaN values in my data. Python’s JSON encoder hates those.

I used a custom encoder to replace NaNs with nulls—fixed it instantly.

Here’s a snippet if you need it:
```python
import json
import math

class NanEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, float) and math.isnan(obj):
return None
return super().default(obj)
```

Messages In This Thread



Users browsing this thread: 1 Guest(s)