Skip to content
YAML

Sequences and Mappings

Lists and key-value maps.

By EZ4Code Team
sequencemappingstructure

Code

# Sequence (list)
fruits:
  - apple
  - banana
  - cherry

# Mapping (object)
person:
  name: Alice
  age: 30

# Sequence of mappings
users:
  - name: Alice
    role: admin
  - name: Bob
    role: user

Explanation

Sequences are ordered lists denoted by a leading dash and space, while mappings are key-value pairs separated by a colon and space. The two can be freely combined, for example a list of maps for database records. Indentation determines nesting, so consistent spaces (not tabs) are essential.

More YAML Snippets