utility-option

jq -e

Exit status depends on last result: zero for a result other than false/null, 1 for false/null, 4 if no valid result produced; other errors also nonzero. Validate type and presence rather than raw truthiness where false is legitimate.

Formal Syntax & Structure

bash syntaxbash
jq -e FILTER FILE

Return Value

exit status

Exit status depends on last result: zero for a result other than false/null, 1 for false/null, 4 if no valid result produced; other errors also nonzero. Validate type and presence rather than raw truthiness where false is legitimate.

Working Example

Example Snippetbash
printf '%s\n' '{"enabled":false,"label":null}' > item.jsonjq -r 'has("enabled"), has("missing"), (.label == null)' item.jsonjq -e '.enabled' item.json >/dev/nullprintf 'value-status=%s\n' "$?"jq -e 'has("enabled") and (.enabled | type == "boolean")' item.json
Bash Reference