utility

jq

External JSON processor; tested jq 1.7. -r emits raw strings; -c compact JSON; -n generates without input. Invalid JSON causes parse failure. Keep structured data or use appropriate framing, not shell splitting. Check exit status before consuming output.

Formal Syntax & Structure

bash syntaxbash
jq [OPTIONS] FILTER [FILE...]

Parameters & Attributes

NameTypeDescription
FILTERstringFixed jq expression
FILEpathJSON input file

Return Value

exit status

External JSON processor; tested jq 1.7. -r emits raw strings; -c compact JSON; -n generates without input. Invalid JSON causes parse failure. Keep structured data or use appropriate framing, not shell splitting. Check exit status before consuming output.

Working Example

Example Snippetbash
printf '%s\n' '{"name":"daily report"}' > item.jsonname=$(jq -er '.name | strings' item.json) || exit 1printf '[%s]\n' "$name"
Bash Reference