Flatten
This recursively flattens arrays.
Flatten
Recursively flattens all arrays
Given a sample.yml file of:
- 1
- - 2
- - - 3then
yq 'flatten' sample.ymlwill output
- 1
- 2
- 3Flatten with depth of one
Given a sample.yml file of:
- 1
- - 2
- - - 3then
yq 'flatten(1)' sample.ymlwill output
- 1
- 2
- - 3Flatten empty array
Given a sample.yml file of:
- []then
yq 'flatten' sample.ymlwill output
[]Flatten array of objects
Given a sample.yml file of:
- foo: bar
- - foo: bazthen
yq 'flatten' sample.ymlwill output
- foo: bar
- foo: bazLast updated
Was this helpful?