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