Entries
Similar to the same named functions in jq
these functions convert to/from an object and an array of key-value pairs. This is most useful for performing operations on keys of maps.
to_entries Map
Given a sample.yml file of:
then
will output
to_entries Array
Given a sample.yml file of:
then
will output
to_entries null
Given a sample.yml file of:
then
will output
from_entries map
Given a sample.yml file of:
then
will output
from_entries with numeric key indices
from_entries always creates a map, even for numeric keys
Given a sample.yml file of:
then
will output
Use with_entries to update keys
Given a sample.yml file of:
then
will output
Custom sort map keys
Use to_entries to convert to an array of key/value pairs, sort the array using sort/sort_by/etc, and convert it back.
Given a sample.yml file of:
then
will output
Use with_entries to filter the map
Given a sample.yml file of:
then
will output
Last updated