Sequence and Hash Data Types of YAML – YAML Example

Sequence:

 A set of ordered values, also known as a sequence/list/array (list)

Array

# sequencearray:   - 12   - 3.34   - 'abc'   - true   - null

Nested Array

- - Cat - Dog - Goldfish

Same as JSON :

[ [ "Cat", "Dog", "Goldfish" ]]

YAML array in Flow Style

animal: [Cat, Dog]

Named Nested Array

# sequence of sequencesnested_array:- [1, 2, 3]- [4, 5, 6]

Mappings

A collection of key-value pairs, also known as a mapping/hashes/dictionary

Hash

animal: pets

Nested hash

hash: subkey:   subsubkey1: 5   subsubkey2: 6 another:   somethingelse: 'Important!'

Hash of hashes 

hash_of_hashes:   number1: 5,   number2: 6

Hash of hashes in Flow style 

flow_style_hash: {number1: 5, number2: 6}

Composite structure

Objects and arrays can be combined to form a composite structure.

languages: - Ruby - Perl - Python websites: YAML: yaml.org  Ruby: ruby-lang.org  Python: python.org  Perl: use.perl.org