Added keys operator

This commit is contained in:
Mike Farah
2021-02-11 10:58:40 +11:00
parent 62acee54c3
commit 0707525b29
6 changed files with 142 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
# Keys
Use the `keys` operator to return map keys or array indices.
## Map keys
Given a sample.yml file of:
```yaml
dog: woof
cat: meow
```
then
```bash
yq eval 'keys' sample.yml
```
will output
```yaml
- dog
- cat
```
## Array keys
Given a sample.yml file of:
```yaml
- apple
- banana
```
then
```bash
yq eval 'keys' sample.yml
```
will output
```yaml
- 0
- 1
```
+3
View File
@@ -0,0 +1,3 @@
# Keys
Use the `keys` operator to return map keys or array indices.