I needed a one-liner JSON payload, but only had the pretty-printed version. And, removing the whitespaces manually was NOT an option. It was super easy on a Mac; just do the following:
- In a terminal, install “jq” with brew like so
brew install jq
- With your pretty-printed JSON in a file:
cat prettyprinted.json | jq -c .