The tag operator can be used to get or set the tag of nodes (e.g. !!str
, !!int
, !!bool
).
Given a sample.yml file of:
a: catb: 5c: 3.2e: truef: []
then
yq eval '.. | tag' sample.yml
will output
!!map!!str!!int!!float!!bool!!seq
Given a sample.yml file of:
a: str
then
yq eval '.a tag = "!!mikefarah"' sample.yml
will output
a: !!mikefarah str
Given a sample.yml file of:
a: catb: 5c: 3.2e: true
then
yq eval '(.. | select(tag == "!!int")) tag= "!!str"' sample.yml
will output
a: catb: "5"c: 3.2e: true