yq/pkg/yqlib/doc/operators/keys.md
2023-05-02 14:07:59 +10:00

387 B

Keys

Use the keys operator to return map keys or array indices.

Check node is a key

Given a sample.yml file of:

a: frog

then

yq '[... | { "p": path | join("."), "isKey": is_key, "tag": tag }]' sample.yml

will output

- p: ""
  isKey: false
  tag: '!!map'
- p: a
  isKey: true
  tag: null
  '!!str': null
- p: a
  isKey: false
  tag: '!!str'