Flatten

This recursively flattens arrays.

Flatten

Recursively flattens all arrays

Given a sample.yml file of:

- 1
- - 2
- - - 3

then

yq 'flatten' sample.yml

will output

- 1
- 2
- 3

Flatten with depth of one

Given a sample.yml file of:

- 1
- - 2
- - - 3

then

will output

Flatten empty array

Given a sample.yml file of:

then

will output

Flatten array of objects

Given a sample.yml file of:

then

will output

Last updated

Was this helpful?