1+ # document start
2+
3+ # Comments in YAML look like this.
4+ # YAML supports single-line comments.
5+
6+ ################
7+ # SCALAR TYPES #
8+ ################
9+
10+ # Our root object (which continues for the entire document) will be a map,
11+ # which is equivalent to a dictionary, hash or object in other languages.
12+ key: value
13+ another_key: Another value goes here.
14+ a_number_value: 100
15+ scientific_notation: 1e+12
16+ hex_notation: 0x123 # evaluates to 291
17+ octal_notation: 0123 # evaluates to 83
18+
19+ # The number 1 will be interpreted as a number, not a boolean.
20+ # If you want it to be interpreted as a boolean, use true.
21+ boolean: true
22+ null_value: null
23+ another_null_value: ~
24+ key with spaces: value
25+
26+ # Yes and No (doesn't matter the case) will be evaluated to boolean
27+ # true and false values respectively.
28+ # To use the actual value use single or double quotes.
29+ no: no # evaluates to "no": false
30+ yes: No # evaluates to "yes": false
31+ not_enclosed: yes # evaluates to "not_enclosed": true
32+ enclosed: "yes" # evaluates to "enclosed": yes
33+
34+ # Notice that strings don't need to be quoted. However, they can be.
35+ however: 'A string, enclosed in quotes.'
36+ 'Keys can be quoted too.': "Useful if you want to put a ':' in your key."
37+ single quotes: 'have ''one'' escape pattern'
38+ double quotes: "have many: \", \0, \t, \u263A, \x0d\x0a == \r\n, and more."
39+ # UTF-8/16/32 characters need to be encoded
40+ Superscript two: \u00B2
41+
42+ # Special characters must be enclosed in single or double quotes
43+ special_characters: "[ John ] & { Jane } - <Doe>"
44+
45+ # Multiple-line strings can be written either as a 'literal block' (using |),
46+ # or a 'folded block' (using '>').
47+ # Literal block turn every newline within the string into a literal newline (\n).
48+ # Folded block removes newlines within the string.
49+ literal_block: |
50+ This entire block of text will be the value of the 'literal_block' key,
51+ with line breaks being preserved.
52+
53+ The literal continues until de-dented, and the leading indentation is
54+ stripped.
55+
56+ Any lines that are 'more-indented' keep the rest of their indentation -
57+ these lines will be indented by 4 spaces.
58+ folded_style: >
59+ This entire block of text will be the value of 'folded_style', but this
60+ time, all newlines will be replaced with a single space.
61+
62+ Blank lines, like above, are converted to a newline character.
63+
64+ 'More-indented' lines keep their newlines, too -
65+ this text will appear over two lines.
66+
67+ # |- and >- removes the trailing blank lines (also called literal/block "strip")
68+ literal_strip: |-
69+ This entire block of text will be the value of the 'literal_strip' key,
70+ with trailing blank line being stripped.
71+ block_strip: >-
72+ This entire block of text will be the value of 'block_strip', but this
73+ time, all newlines will be replaced with a single space and
74+ trailing blank line being stripped.
75+
76+ # |+ and >+ keeps trailing blank lines (also called literal/block "keep")
77+ literal_keep: |+
78+ This entire block of text will be the value of the 'literal_keep' key,
79+ with trailing blank line being kept.
80+
81+ block_keep: >+
82+ This entire block of text will be the value of 'block_keep', but this
83+ time, all newlines will be replaced with a single space and
84+ trailing blank line being kept.
85+
86+ ####################
87+ # COLLECTION TYPES #
88+ ####################
89+
90+ # Nesting uses indentation. 2 space indent is preferred (but not required).
91+ a_nested_map:
92+ key: value
93+ another_key: Another Value
94+ another_nested_map:
95+ hello: hello
96+
97+ # Maps don't have to have string keys.
98+ 0.25: a float key
99+
100+ # Keys can also be complex, like multi-line objects
101+ # We use ? followed by a space to indicate the start of a complex key.
102+ ? |
103+ This is a key
104+ that has multiple lines
105+ : and this is its value
106+
107+ # YAML also allows mapping between sequences with the complex key syntax
108+ # Some language parsers might complain
109+ # An example
110+ ? - Manchester United
111+ - Real Madrid
112+ : [ 2001-01-01, 2002-02-02 ]
113+
114+ # Sequences (equivalent to lists or arrays) look like this
115+ # (note that the '-' counts as indentation):
116+ a_sequence:
117+ - Item 1
118+ - Item 2
119+ - 0.5 # sequences can contain disparate types.
120+ - Item 4
121+ - key: value
122+ another_key: another_value
123+ - - This is a sequence
124+ - inside another sequence
125+ - - - Nested sequence indicators
126+ - can be collapsed
127+
128+ # Since YAML is a superset of JSON, you can also write JSON-style maps and
129+ # sequences:
130+ json_map: { "key": "value" }
131+ json_seq: [ 3, 2, 1, "takeoff" ]
132+ and quotes are optional: { key: [ 3, 2, 1, takeoff ] }
133+
134+ #######################
135+ # EXTRA YAML FEATURES #
136+ #######################
137+
138+ # YAML also has a handy feature called 'anchors', which let you easily duplicate
139+ # content across your document.
140+ # Anchors identified by & character which define the value.
141+ # Aliases identified by * character which acts as "see above" command.
142+ # Both of these keys will have the same value:
143+ anchored_content: &anchor_name This string will appear as the value of two keys.
144+ other_anchor: *anchor_name
145+
146+ # Anchors can be used to duplicate/inherit properties
147+ base: &base
148+ name: Everyone has same name
149+
150+ # The expression << is called 'Merge Key Language-Independent Type'. It is used to
151+ # indicate that all the keys of one or more specified maps should be inserted
152+ # into the current map.
153+ # NOTE: If key already exists alias will not be merged
154+ foo:
155+ <<: *base # doesn't merge the anchor
156+ age: 10
157+ name: John
158+ bar:
159+ <<: *base # base anchor will be merged
160+ age: 20
161+
162+ # foo name won't be changed and it will be: John. On the other hand, bar's name will be changed to the base one: Everyone has same name
163+
164+ # YAML also has tags, which you can use to explicitly declare types.
165+ # Syntax: !![typeName] [value]
166+ explicit_boolean: !!bool true
167+ explicit_integer: !!int 42
168+ explicit_float: !!float -42.24
169+ explicit_string: !!str 0.5
170+ explicit_datetime: !!timestamp 2022-11-17 12:34:56.78 +9
171+ explicit_null: !!null null
172+
173+ # Some parsers implement language specific tags, like this one for Python's
174+ # complex number type.
175+ python_complex_number: !!python/complex 1+2j
176+
177+ # We can also use yaml complex keys with language specific tags
178+ ? !!python/tuple [ 5, 7 ]
179+ : Fifty Seven
180+ # Would be {(5, 7): 'Fifty Seven'} in Python
181+
182+ ####################
183+ # EXTRA YAML TYPES #
184+ ####################
185+
186+ # Strings and numbers aren't the only scalars that YAML can understand.
187+ # ISO-formatted date and datetime literals are also parsed.
188+ datetime_canonical: 2001-12-15T02:59:43.1Z
189+ datetime_space_separated_with_time_zone: 2001-12-14 21:59:43.10 -5
190+ date_implicit: 2002-12-14
191+ date_explicit: !!timestamp 2002-12-14
192+
193+ # The !!binary tag indicates that a string is actually a base64-encoded
194+ # representation of a binary blob.
195+ gif_file: !!binary |
196+ R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
197+ OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
198+ +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
199+ AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
200+
201+ # YAML also has a set type, which looks like this:
202+ set:
203+ ? item1
204+ ? item2
205+ ? item3
206+ or: { item1, item2, item3 }
207+
208+ # Sets are just maps with null values; the above is equivalent to:
209+ set2:
210+ item1: null
211+ item2: null
212+ item3: null
213+
214+ ... # document end
0 commit comments