Yaml, yml online - format - werkzeug
permalink Edit source here:
x
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
# Rotates - no light/dark sides. Mercury
55
# Deadliest. Aptly named. Venus
56
# Mostly dirt. Earth
57
# Seems empty. Mars
58
# The king. Jupiter
59
# Pretty. Saturn
60
# Where the sun hardly shines. Uranus
61
# Boring. No rings. Neptune
62
# You call this a planet? Pluto
63
Flow style !!seq Mercury Venus Earth Mars # Rocks
64
Jupiter# Gas Saturn Uranus Neptune
65
Pluto # Overrated
66
67
68
# Scalar Types #################################################################
69
################################################################################
70
71
# http://yaml.org/type/bool.html ----------------------------------------------#
72
73
bool
74
true
75
True
76
TRUE
77
false
78
False
79
FALSE
80
81
# http://yaml.org/type/float.html ---------------------------------------------#
82
83
float
84
canonical 6.8523015e+5
85
exponentioal 685.230_15e+03
86
fixed 685_230.15
87
sexagesimal 190 2030.15
88
negative infinity -.inf
89
not a number .NaN
90
91
# http://yaml.org/type/int.html -----------------------------------------------#
92
93
int
94
canonical685230
95
decimal +685_230
96
octal02472256
97
hexadecimal 0x_0A_74_AE
98
binary 0b1010_0111_0100_1010_1110
99
sexagesimal 190 2030
100
101
# http://yaml.org/type/merge.html ---------------------------------------------#
102
103
merge
104
&CENTER { x 1, y 2
105
&LEFT { x 0, y 2
106
&BIG { r 10
107
&SMALL { r 1
108
109
# All the following maps are equal:
110
111
# Explicit keys
112
x 1
113
y 2
114
r 10
115
label nothing
116
117
# Merge one map
118
<< *CENTER
119
r 10
120
label center
121
122
# Merge multiple maps
123
<< *CENTER *BIG
124
label center/big
125
126
# Override
127
<< *BIG *LEFT *SMALL
128
x 1
129
label big/left/small
130
131
# http://yaml.org/type/null.html ----------------------------------------------#
132
133
null
134
# This mapping has four keys,
135
# one has a value.
136
empty
137
canonical ~
138
english null
139
~ null key
140
# This sequence has five
141
# entries, two have values.
142
sparse
143
~
144
2nd entry
145
-
146
4th entry
147
Null
148
149
# http://yaml.org/type/str.html -----------------------------------------------#
150
151
string abcd
152
153
# http://yaml.org/type/timestamp.html -----------------------------------------#
154
155
timestamp
156
canonical 2001-12-15T02 59 43.1Z
157
valid iso8601 2001-12-14t21 59 43.10-05 00
158
space separated 2001-12-14 21 59 43.10 -5
159
no time zone (Z) 2001-12-15 2 59 43.10
160
date (00:00:00Z) 2002-12-14
161
162
163
# JavaScript Specific Types ####################################################
164
################################################################################
165
166
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp
167
168
regexp
169
simple !!js/regexp foobar
170
modifiers !!js/regexp /foobar/mi
171
172
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/undefined
173
174
undefined !!js/undefined ~
175
176
# https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function
177
178
function !!js/function >
179
function foobar()
180
return 'Wow! JS-YAML Rocks!';
181
182
183
184
# Custom types #################################################################
185
################################################################################
186
187
188
# JS-YAML allows you to specify a custom YAML types for your structures.
189
# This is a simple example of custom constructor defined in `js/demo.js` for
190
# custom `!sexy` type:
191
#
192
# var SexyYamlType = new jsyaml.Type('!sexy', {
193
# kind: 'sequence',
194
# construct: function (data) {
195
# return data.map(function (string) { return 'sexy ' + string; });
196
# }
197
# });
198
#
199
# var SEXY_SCHEMA = jsyaml.Schema.create([ SexyYamlType ]);
200
#
201
# result = jsyaml.load(yourData, { schema: SEXY_SCHEMA });
202
203
foobar !sexy
204
bunny
205
chocolate
206
Result (JS object dump):
{ map:
{ 'Block style': { Clark: 'Evans', Ingy: 'döt Net', Oren: 'Ben-Kiki' },
'Flow style': { Clark: 'Evans', Ingy: 'döt Net', Oren: 'Ben-Kiki' } },
omap:
{ Bestiary:
[ { aardvark: 'African pig-like ant eater. Ugly.' },
{ anteater: 'South-American ant eater. Two species.' },
{ anaconda: 'South-American constrictor snake. Scaly.' } ],
Numbers: [ { one: 1 }, { two: 2 }, { three: 3 } ] },
pairs:
{ 'Block tasks':
[ [ 'meeting', 'with team.' ],
[ 'meeting', 'with boss.' ],
[ 'break', 'lunch.' ],
[ 'meeting', 'with client.' ] ],
'Flow tasks': [ [ 'meeting', 'with team' ], [ 'meeting', 'with boss' ] ] },
set:
{ 'baseball players': { 'Mark McGwire': null, 'Sammy Sosa': null, 'Ken Griffey': null },
'baseball teams':
{ 'Boston Red Sox': null,
'Detroit Tigers': null,
'New York Yankees': null } },
seq:
{ 'Block style':
[ 'Mercury',
'Venus',
'Earth',
'Mars',
'Jupiter',
'Saturn',
'Uranus',
'Neptune',
'Pluto' ],
'Flow style':
[ 'Mercury',
'Venus',
'Earth',
'Mars',
'Jupiter',
'Saturn',
'Uranus',
'Neptune',
'Pluto' ] },
bool: [ true, true, true, false, false, false ],
float:
{ canonical: 685230.15,
exponentioal: 685230.15,
fixed: 685230.15,
sexagesimal: 685230.15,
'negative infinity': -Infinity,
'not a number': NaN },
int:
{ canonical: 685230,
decimal: 685230,
octal: 685230,
hexadecimal: 685230,
binary: 685230,
sexagesimal: 685230 },
merge:
[ { x: 1, y: 2 },
{ x: 0, y: 2 },
{ r: 10 },
{ r: 1 },
{ x: 1, y: 2, r: 10, label: 'nothing' },
{ x: 1, y: 2, r: 10, label: 'center' },
{ x: 1, y: 2, r: 10, label: 'center/big' },
{ r: 10, x: 1, y: 2, label: 'big/left/small' } ],
null:
{ empty: null,
canonical: null,
english: null,
null: 'null key',
sparse: [ null, '2nd entry', null, '4th entry', null ] },
string: 'abcd',
timestamp:
{ canonical: Sat Dec 15 2001 02:59:43 GMT+0000 (Coordinated Universal Time),
'valid iso8601': Sat Dec 15 2001 02:59:43 GMT+0000 (Coordinated Universal Time),
'space separated': Sat Dec 15 2001 02:59:43 GMT+0000 (Coordinated Universal Time),
'no time zone (Z)': Sat Dec 15 2001 02:59:43 GMT+0000 (Coordinated Universal Time),
'date (00:00:00Z)': Sat Dec 14 2002 00:00:00 GMT+0000 (Coordinated Universal Time) },
regexp: { simple: /foobar/, modifiers: /foobar/im },
undefined: undefined,
function: [Function: anonymous],
foobar: [ 'sexy bunny', 'sexy chocolate' ] }