Zum Hauptinhalt springen

YAML

  • textbasiertes Dateiformat
  • zur Datenserialisierung
  • rekursives Akronym: "YAML Ain't Markup Language"

Links

Syntax

# this is a comment

# key-value: with colon+space
key: value

# section
---

--- # lists: with hyphen+space
list:
- Casablanca
- North by Northwest
- The Man Who Wasn't There
- key1OfObjectInList: value # block in list
key2OfObjectInList: value2
key3OfObjectInList:
- item1
- item2: 90 # block in list

inlineList: [ milk, pumpkin pie, eggs, juice ]

--- # blocks / objects
# IMPORTANT: shifting must consist of two spaces! No tabs!
intendedBlock:
name: John Smith
age: 33
inlineBlock: { name: John Smith, age: 33 }

--- # text
text1: "This is a text"
text2: 'This is a text'
text3: This is a text # most used
text4: "This is a text with an escaped sequence\nand a second line"

multiLineText1: |
In this text, newlines are preserved.
This is a second line.
By default, indentation of the first line is ignored.

So he carefully sat on the ceiling
multiLineText2: >
In this text, newlines are not preserved.
Wrapped lines
will be folded into
a single paragraph.

But blank lines denote
paragraph breaks.

--- # numbers
integer: 123 # an integer
numberAsString: "123" # a string, disambiguated by quotes
float: 123.0 # a float

--- # booleans
booleanTrue: true
booleanFalse: false

--- # explicit data types (prefixed by !!)
explicitFloat: !!float 123
explicitStringOfInteger: !!str 123
explicitStringOfBoolean: !!str true

--- # binary
picture: !!binary |
R0lGODdhDQAIAIAAAAAAANn
Z2SwAAAAADQAIAAACF4SDGQ
ar3xxbJ9p0qa7R0YxwzaFME
1IAADs=

--- # anchor and reference to it
- step: &id001 # anchor
instrument: Lasik 2000
pulseEnergy: 5.4

- step: &id002
instrument: Lasik 2000
pulseEnergy: 5.0
- Instrument1: *id001 # refers to the first step (anchor &id001)
- Instrument2: *id002 # refers to the second step (anchor &id002)

Hinweis: Booleans werden in YAML 1.1 anders als in YAML 1.2.2 definiert. Siehe: