Many data formats can encode lists at their top-level, such as JSON and TOML arrays, and YAML sequences. This guide demonstrates how to query such a list using the cue export command.

data.yaml
- A
- B
- C
- D
- E
TERMINAL
$ cue export data.yaml -l foo: -e foo[2]
"C"

The cue command shown here uses two flags to query a top-level list and export one of its elements:

  • the -l flag places the data input at an addressable location using an arbitrary identifier, foo
  • the -e flag refers to that location using the identifier, and selects the element at list index 2