Red Cricket
Red Cricket

Reputation: 10470

Is there a way to reference a particular element in a yaml array?

Is there a way to reference a particular element in a yaml array? For example if I have this bit of yaml:

node_list:
  - one
  - two
  - three

Can I do something like this:

first_node: node_list[0]

Upvotes: 7

Views: 5817

Answers (1)

flyx
flyx

Reputation: 39768

Only with anchors & aliases. Example:

node_list:
  - &first one
  - two
  - three
first_node: *first

There is no equivalent to XPath in YAML, at least not officially.

Upvotes: 11

Related Questions