How to Use json.dumps Without Newlines for Compact Output?

16 Replies, 2289 Views

Hey! For json dumps without newlines, you’re on the right track. Just a heads-up, some IDEs or text editors might auto-format JSON, so it could look like there are newlines when there aren’t.

Try running this in a plain terminal:
```python
import json
print(json.dumps({"a": 1, "b": 2}, indent=None, separators=(',', ':')))
```
If it still doesn’t work, maybe share your full code snippet so we can debug further.

Messages In This Thread



Users browsing this thread: 1 Guest(s)