If json.dump python isn’t writing, here’s what I’d check:
- Are you using `with`? If not, the file might not flush.
- Is the data valid? Try `json.dumps(data)` first to see if it throws errors.
- Permissions? Maybe you can’t write to that folder.
Example:
```python
import json
data = {"example": True}
with open("test.json", "w") as f:
json.dump(data, f, indent=4) # indent for pretty print
```
Indent just adds whitespace—useful for debugging but not needed for machines.
- Are you using `with`? If not, the file might not flush.
- Is the data valid? Try `json.dumps(data)` first to see if it throws errors.
- Permissions? Maybe you can’t write to that folder.
Example:
```python
import json
data = {"example": True}
with open("test.json", "w") as f:
json.dump(data, f, indent=4) # indent for pretty print
```
Indent just adds whitespace—useful for debugging but not needed for machines.
