Ordered Mapping 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:omap

Shorthand:

!!omap

Kind:

Sequence.

Definition:

Ordered sequence of key:value pairs without duplicates.

A common type used for modeling is the ordered list of named values, where duplicates are not allowed. For example, this is the basic collection data type used by the PHP language.

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

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

Example 1. !!omap Examples

# Explicitly typed ordered map (dictionary).
Bestiary: !!omap
  - aardvark: African pig-like ant eater. Ugly.
  - anteater: South-American ant eater. Two species.
  - anaconda: South-American constrictor snake. Scaly.
  # Etc.
# Flow style
Numbers: !!omap [ one: 1, two: 2, three : 3 ]