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

22 Replies, 1696 Views

I’ve been using `json.dumps(my_dict, separators=(',', ':'))` for ages now. It’s the simplest way to get json dumps without newlines in a dictionary. If you’re into CLI tools, `jq` is awesome for manipulating JSON from the terminal. Just pipe your output through `jq -c` for compact JSON.

Messages In This Thread



Users browsing this thread: 1 Guest(s)