[jq] Supply a fallback for false or null

Created on November 30, 2026

Use jq's // operator to provide a fallback value. In this example the name field is null.

echo '{"name":null}' | jq '.name // "unknown"'
"unknown"

A missing key also evaluates to null in this lookup, so the same filter supplies the fallback.

echo '{}' | jq '.name // "unknown"'
"unknown"

The operator also falls back for false. Account for that when false is a meaningful value in your data.

jq