Kind
The kind operator identifies the type of a node as either scalar, map, or seq.
This can be used for filtering or transforming nodes based on their type.
Note that null values are treated as scalar.
Given a sample.yml file of:
a: cat
b: 5
c: 3.2
e: true
f: []
g: {}
h: null
then
yq '.. | kind' sample.yml
will output
map
scalar
scalar
scalar
scalar
seq
map
scalar
Unlike tag, kind is not affected by custom tags.
Given a sample.yml file of:
then
will output
An example of how you can use kind
Given a sample.yml file of:
then
will output