Tombart
Tombart

Reputation: 32418

Map key to its child value attribute

I have a simple YAML:

host1:
  type: A
  value: 10.0.0.1
host2:
  type: A
  value: 10.0.0.2

which I want to map key-value pairs, like this:

host1: 10.0.0.1
host2: 10.0.0.2

How can I do this using yq?

Upvotes: 0

Views: 27

Answers (1)

pmf
pmf

Reputation: 36088

Apply .value to all items of the root:

.[] |= .value
# or
map_values(.value)

Works with both kislyuk/yq and mikefarah/yq.

Upvotes: 1

Related Questions