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 index2
Related content
- Concept Guide: Using the cue export command – including
using the
-l
flag and using the-e
flag - How-to Guide: Exporting fields whose names are not valid identifiers
- How-to Guide: Refering to fields whose names are not valid identifiers
- Reference: The cue export command