Ugh, been there. json.dump hates certain Python types—like sets or datetime. If your data’s a "hot mess," try converting non-standard types first.
For example:
```python
import json
from datetime import datetime
data = {"time": datetime.now()}
# This’ll fail! Instead, do:
data["time"] = str(data["time"])
json.dump(data, f)
```
Or use `default=str` in json.dump, but it’s a band-aid. For heavy lifting, check out `orjson`—way faster and less picky.
For example:
```python
import json
from datetime import datetime
data = {"time": datetime.now()}
# This’ll fail! Instead, do:
data["time"] = str(data["time"])
json.dump(data, f)
```
Or use `default=str` in json.dump, but it’s a band-aid. For heavy lifting, check out `orjson`—way faster and less picky.
