jq Arrays and Objects/Check object contains subset

Test whether an object includes certain key-value pairs.

Section: Object Basics

Check object contains subset

bash
bash
echo '{"role":"admin","active":true}' | jq 'contains({role: "admin"})'
Explanation

Very useful for policy and config checks.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Object Basics
Object values
Return all object values as an array.
OpenIn sheetbashsame section
Keys unsorted
Return keys preserving insertion semantics when possible.
OpenIn sheetbashsame section
Get JSON type
Return the type of the current value.
OpenIn sheetbashsame section
Project specific fields
Build a smaller object from chosen keys.
OpenIn sheetbashsame section
Build nested object
Construct nested output structures.
OpenIn sheetbashsame section
Map object values
Transform each value while keeping keys unchanged.
OpenIn sheetbash2 tag match