Has
This operation returns true if the key exists in a map (or index in an array), false otherwise.
Has map key
Given a sample.yml file of:
- a: yes
- a: ~
- a:
- b: nopethen
yq '.[] | has("a")' sample.ymlwill output
true
true
true
falseSelect, checking for existence of deep paths
Simply pipe in parent expressions into has
Given a sample.yml file of:
then
will output
Has array index
Given a sample.yml file of:
then
will output
Last updated
Was this helpful?