mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-26 00:15:36 +00:00
405 B
405 B
Array to Map
Use this operator to convert an array to..a map. Skips over null values.
Behind the scenes, this is implemented using reduce:
(.[] | select(. != null) ) as $i ireduce({}; .[$i | key] = $i)
Simple example
Given a sample.yml file of:
cool:
- null
- null
- hello
then
yq '.cool |= array_to_map' sample.yml
will output
cool:
2: hello