Skip to main content
Version: Next



fields return the flattened path names of a record


fields(r: record) -> [[string]]


The fields function returns an array of string arrays of all the field names in record r. A field's path name is representing by an array of strings since the dot separator is an unreliable indicator of field boundaries as . itself can appear in a field name.

error("missing") is returned if r is not a record.


Extract the fields of a nested record:

echo '{a:1,b:2,c:{d:3,e:4}}' | zq -z 'yield fields(this)' -



Easily convert to dotted names if you prefer:

echo '{a:1,b:2,c:{d:3,e:4}}' | zq -z 'over fields(this) | yield join(this,".")' -



A record is expected:

echo 1 | zq -z 'yield {f:fields(this)}' -