Pairs Language-Independent Type for YAML™ Version 1.1

Working Draft 2005-01-18

Oren Ben-Kiki

Clark Evans

Brian Ingerson

This document may be freely copied provided it is not modified.

Status

This specification is a draft reflecting consensus reached by members of the yaml-core mailing list. Any questions regarding this draft should be raised on this list.


URI:

tag:yaml.org,2002:pairs

Shorthand:

!!pairs

Kind:

Sequence.

Definition:

Ordered sequence of key:value pairs allowing duplicates.

A common type used for modeling is the ordered list of named values, allowing duplicates. For example, this is one of the basic constructs used to model XML data. YAML provides a shorthand notation for representing this data type as a sequence of one-key mappings.

Most programming languages do not have a built-in native data type for supporting pairs. Such data types are usually provided by libraries. If no such data type is available, an application may resort to loading !!pairs into a native array of hash tables containing one key each.

The !!pairs tag may be given explicitly. Alternatively, the application may choose to implicitly type a sequence of single-key mappings to pairs. In this case, an explicit !!seq transfer must be given to sequences of single-key mappings that do not represent pairs.

Example 1. !!pairs Examples

# Explicitly typed pairs.
Block tasks: !!pairs
  - meeting: with team.
  - meeting: with boss.
  - break: lunch.
  - meeting: with client.
Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]