Validate JSON

Check if a string is valid JSON.

Code

General
echo "$str" | jq . >/dev/null 2>&1 && echo "true" || echo "false"

Parameters

The string to validate as JSON

Server

More Bash Snippets