1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00
yq/pkg/yqlib/doc/Collect into Array.md
Mike Farah f7f8bed955 wip
2020-12-27 09:55:21 +11:00

43 lines
450 B
Markdown

# Collect into Array
This creates an array using the expression between the square brackets.
## Collect empty
Running
```bash
yq eval --null-input '[]'
```
will output
```yaml
[]
```
## Collect single
Running
```bash
yq eval --null-input '["cat"]'
```
will output
```yaml
- cat
```
## Collect many
Given a sample.yml file of:
```yaml
a: cat
b: dog
'': null
```
then
```bash
yq eval '[.a, .b]' sample.yml
```
will output
```yaml
- cat
- dog
```