n1: 1 # integer
n2: 1.234 # float
s1: 'abc' # string
s2: "abc" # string
s3: abc # string
b: false # boolean type
d: 2015-04-05 # date type
some_thing: &VAR_NAME foobar
other_thing: *VAR_NAME
# A single line comment example
# block level comment example
# comment line 1
# comment line 2
# comment line 3
description: |
hello
world
parent: &defaults
a: 2
b: 3
child:
<<: *defaults
b: 4
values: &ref
- Will be
- reused below
other_values:
i_am_ref: *ref
description: >
hello
world
---
document: this is doc 1
---
document: this is doc 2
YAML uses --- to separate directives from document content.
- Mark McGwire
- Sammy Sosa
- Ken Griffey
hr: 65 # Home runs
avg: 0.278 # Batting average
rbi: 147 # Runs Batted In
attributes:
- a1
- a2
methods: [getter, setter]
children:
- name: Jimmy Smith
age: 15
- name: Jimmy Smith
age: 15
-
name: Sammy Sosa
age: 12
Mark McGwire: {hr: 65, avg: 0.278}
Sammy Sosa: {
hr: 63,
avg: 0.288
}
my_sequences:
- [1, 2, 3]
- [4, 5, 6]
-
- 7
- 8
- 9
- 0
Jack:
id: 1
name: Franc
salary: 25000
hobby:
- a
- b
location: {country: "A", city: "A-A"}
set1: !!set
? one
? two
set2: !!set {'one', "two"}
Sets are represented as a Mapping where each key is associated with a null value
ordered: !!omap
- Mark McGwire: 65
- Sammy Sosa: 63
- Ken Griffy: 58
Modifiers can be combined (|2-, >+1)
…
A YAML cheat sheet is a compact document that provides a quick and handy reference guide for the basics of YAML syntax and its conventions. This document is handy when working with YAML files, especially when you’re learning the language or need a refresher on its basic structure and syntax.
Some basic concepts:
Good specifications will always improve programmer productivity far better than any programming tool or technique.
…