I've been looking for a way to uglify some JSON while in my bash console. This help using it afterward in another command (for example, to pass json inline to httpie
)
Giving:
{
"foo": "lorem",
"bar": "ipsum"
}
I want to obtain:
{"foo":"lorem","bar":"ipsum"}
NOTE: this question is intentionnaly greatly inspired by it's pretty-print counterpart. However, googling for bash minify json didn't give me a proper result, hence this questions for the minify/uglify.
Use your JSON REST URL to minify. Click on the URL button, Enter URL and Submit. Users can also minify the JSON file by uploading the file. Once you have minified JSON Data.
The default is (', ', ': ') if indent is None and (',', ': ') otherwise. To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.
You can use jq -c
(compact) option.
jq -c . < input.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With