Working with JSON Using JQ
Use jq
to manipulate JSON on the command line.
Check if JSON is empty
To check if a JSON file or object is empty, pipe it to jq . == {}
Example: Check if POST request returns an empty body
sh
IS_EMPTY=$(curl -X POST <url> | jq ". == {}")
echo $IS_EMPTY
IS_EMPTY=$(curl -X POST <url> | jq ". == {}")
echo $IS_EMPTY