yq/pkg/yqlib/doc/operators/headers/array-to-map.md

10 lines
268 B
Markdown
Raw Normal View History

2022-11-08 02:40:00 +00:00
# Array to Map
2022-11-13 00:16:01 +00:00
Use this operator to convert an array to..a map. The indices are used as map keys, null values in the array are skipped over.
2022-11-08 02:40:00 +00:00
Behind the scenes, this is implemented using reduce:
```
(.[] | select(. != null) ) as $i ireduce({}; .[$i | key] = $i)
```