Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80684 views
1
---
2
# Collection Types #############################################################
3
################################################################################
4
5
# http://yaml.org/type/map.html -----------------------------------------------#
6
7
map:
8
# Unordered set of key: value pairs.
9
Block style: !!map
10
Clark : Evans
11
Ingy : döt Net
12
Oren : Ben-Kiki
13
Flow style: !!map { Clark: Evans, Ingy: döt Net, Oren: Ben-Kiki }
14
15
# http://yaml.org/type/omap.html ----------------------------------------------#
16
17
omap:
18
# Explicitly typed ordered map (dictionary).
19
Bestiary: !!omap
20
- aardvark: African pig-like ant eater. Ugly.
21
- anteater: South-American ant eater. Two species.
22
- anaconda: South-American constrictor snake. Scaly.
23
# Etc.
24
# Flow style
25
Numbers: !!omap [ one: 1, two: 2, three : 3 ]
26
27
# http://yaml.org/type/pairs.html ---------------------------------------------#
28
29
pairs:
30
# Explicitly typed pairs.
31
Block tasks: !!pairs
32
- meeting: with team.
33
- meeting: with boss.
34
- break: lunch.
35
- meeting: with client.
36
Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
37
38
# http://yaml.org/type/set.html -----------------------------------------------#
39
40
set:
41
# Explicitly typed set.
42
baseball players: !!set
43
? Mark McGwire
44
? Sammy Sosa
45
? Ken Griffey
46
# Flow style
47
baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees }
48
49
# http://yaml.org/type/seq.html -----------------------------------------------#
50
51
seq:
52
# Ordered sequence of nodes
53
Block style: !!seq
54
- Mercury # Rotates - no light/dark sides.
55
- Venus # Deadliest. Aptly named.
56
- Earth # Mostly dirt.
57
- Mars # Seems empty.
58
- Jupiter # The king.
59
- Saturn # Pretty.
60
- Uranus # Where the sun hardly shines.
61
- Neptune # Boring. No rings.
62
- Pluto # You call this a planet?
63
Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks
64
Jupiter, Saturn, Uranus, Neptune, # Gas
65
Pluto ] # Overrated
66
67
68
# Scalar Types #################################################################
69
################################################################################
70
71
# http://yaml.org/type/binary.html --------------------------------------------#
72
73
binary:
74
canonical: !!binary "\
75
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
76
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
77
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
78
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
79
generic: !!binary |
80
R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
81
OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
82
+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
83
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
84
description:
85
The binary value above is a tiny arrow encoded as a gif image.
86
87
# http://yaml.org/type/bool.html ----------------------------------------------#
88
89
bool:
90
- true
91
- True
92
- TRUE
93
- false
94
- False
95
- FALSE
96
97
# http://yaml.org/type/float.html ---------------------------------------------#
98
99
float:
100
canonical: 6.8523015e+5
101
exponentioal: 685.230_15e+03
102
fixed: 685_230.15
103
sexagesimal: 190:20:30.15
104
negative infinity: -.inf
105
not a number: .NaN
106
107
# http://yaml.org/type/int.html -----------------------------------------------#
108
109
int:
110
canonical: 685230
111
decimal: +685_230
112
octal: 02472256
113
hexadecimal: 0x_0A_74_AE
114
binary: 0b1010_0111_0100_1010_1110
115
sexagesimal: 190:20:30
116
117
# http://yaml.org/type/merge.html ---------------------------------------------#
118
119
merge:
120
- &CENTER { x: 1, y: 2 }
121
- &LEFT { x: 0, y: 2 }
122
- &BIG { r: 10 }
123
- &SMALL { r: 1 }
124
125
# All the following maps are equal:
126
127
- # Explicit keys
128
x: 1
129
y: 2
130
r: 10
131
label: nothing
132
133
- # Merge one map
134
<< : *CENTER
135
r: 10
136
label: center
137
138
- # Merge multiple maps
139
<< : [ *CENTER, *BIG ]
140
label: center/big
141
142
- # Override
143
<< : [ *BIG, *LEFT, *SMALL ]
144
x: 1
145
label: big/left/small
146
147
# http://yaml.org/type/null.html ----------------------------------------------#
148
149
null:
150
# This mapping has four keys,
151
# one has a value.
152
empty:
153
canonical: ~
154
english: null
155
~: null key
156
# This sequence has five
157
# entries, two have values.
158
sparse:
159
- ~
160
- 2nd entry
161
-
162
- 4th entry
163
- Null
164
165
# http://yaml.org/type/str.html -----------------------------------------------#
166
167
string: abcd
168
169
# http://yaml.org/type/timestamp.html -----------------------------------------#
170
171
timestamp:
172
canonical: 2001-12-15T02:59:43.1Z
173
valid iso8601: 2001-12-14t21:59:43.10-05:00
174
space separated: 2001-12-14 21:59:43.10 -5
175
no time zone (Z): 2001-12-15 2:59:43.10
176
date (00:00:00Z): 2002-12-14
177
178
179
# JavaScript Specific Types ####################################################
180
################################################################################
181
182
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp
183
184
regexp:
185
simple: !!js/regexp foobar
186
modifiers: !!js/regexp /foobar/mi
187
188
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined
189
190
undefined: !!js/undefined ~
191
192
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function
193
194
function: !!js/function >
195
function foobar() {
196
return 'Wow! JS-YAML Rocks!';
197
}
198
199