example.yaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. #
  2. # Examples from the Preview section of the YAML specification
  3. # (http://yaml.org/spec/1.2/#Preview)
  4. #
  5. # Sequence of scalars
  6. ---
  7. - Mark McGwire
  8. - Sammy Sosa
  9. - Ken Griffey
  10. # Mapping scalars to scalars
  11. ---
  12. hr: 65 # Home runs
  13. avg: 0.278 # Batting average
  14. rbi: 147 # Runs Batted In
  15. # Mapping scalars to sequences
  16. ---
  17. american:
  18. - Boston Red Sox
  19. - Detroit Tigers
  20. - New York Yankees
  21. national:
  22. - New York Mets
  23. - Chicago Cubs
  24. - Atlanta Braves
  25. # Sequence of mappings
  26. ---
  27. -
  28. name: Mark McGwire
  29. hr: 65
  30. avg: 0.278
  31. -
  32. name: Sammy Sosa
  33. hr: 63
  34. avg: 0.288
  35. # Sequence of sequences
  36. ---
  37. - [name , hr, avg ]
  38. - [Mark McGwire, 65, 0.278]
  39. - [Sammy Sosa , 63, 0.288]
  40. # Mapping of mappings
  41. ---
  42. Mark McGwire: {hr: 65, avg: 0.278}
  43. Sammy Sosa: {
  44. hr: 63,
  45. avg: 0.288
  46. }
  47. # Two documents in a stream
  48. --- # Ranking of 1998 home runs
  49. - Mark McGwire
  50. - Sammy Sosa
  51. - Ken Griffey
  52. --- # Team ranking
  53. - Chicago Cubs
  54. - St Louis Cardinals
  55. # Documents with the end indicator
  56. ---
  57. time: 20:03:20
  58. player: Sammy Sosa
  59. action: strike (miss)
  60. ...
  61. ---
  62. time: 20:03:47
  63. player: Sammy Sosa
  64. action: grand slam
  65. ...
  66. # Comments
  67. ---
  68. hr: # 1998 hr ranking
  69. - Mark McGwire
  70. - Sammy Sosa
  71. rbi:
  72. # 1998 rbi ranking
  73. - Sammy Sosa
  74. - Ken Griffey
  75. # Anchors and aliases
  76. ---
  77. hr:
  78. - Mark McGwire
  79. # Following node labeled SS
  80. - &SS Sammy Sosa
  81. rbi:
  82. - *SS # Subsequent occurrence
  83. - Ken Griffey
  84. # Mapping between sequences
  85. ---
  86. ? - Detroit Tigers
  87. - Chicago cubs
  88. :
  89. - 2001-07-23
  90. ? [ New York Yankees,
  91. Atlanta Braves ]
  92. : [ 2001-07-02, 2001-08-12,
  93. 2001-08-14 ]
  94. # Inline nested mapping
  95. ---
  96. # products purchased
  97. - item : Super Hoop
  98. quantity: 1
  99. - item : Basketball
  100. quantity: 4
  101. - item : Big Shoes
  102. quantity: 1
  103. # Literal scalars
  104. --- | # ASCII art
  105. \//||\/||
  106. // || ||__
  107. # Folded scalars
  108. --- >
  109. Mark McGwire's
  110. year was crippled
  111. by a knee injury.
  112. # Preserved indented block in a folded scalar
  113. ---
  114. >
  115. Sammy Sosa completed another
  116. fine season with great stats.
  117. 63 Home Runs
  118. 0.288 Batting Average
  119. What a year!
  120. # Indentation determines scope
  121. ---
  122. name: Mark McGwire
  123. accomplishment: >
  124. Mark set a major league
  125. home run record in 1998.
  126. stats: |
  127. 65 Home Runs
  128. 0.278 Batting Average
  129. # Quoted scalars
  130. ---
  131. unicode: "Sosa did fine.\u263A"
  132. control: "\b1998\t1999\t2000\n"
  133. hex esc: "\x0d\x0a is \r\n"
  134. single: '"Howdy!" he cried.'
  135. quoted: ' # not a ''comment''.'
  136. tie-fighter: '|\-*-/|'
  137. # Multi-line flow scalars
  138. ---
  139. plain:
  140. This unquoted scalar
  141. spans many lines.
  142. quoted: "So does this
  143. quoted scalar.\n"
  144. # Integers
  145. ---
  146. canonical: 12345
  147. decimal: +12_345
  148. sexagesimal: 3:25:45
  149. octal: 014
  150. hexadecimal: 0xC
  151. # Floating point
  152. ---
  153. canonical: 1.23015e+3
  154. exponential: 12.3015e+02
  155. sexagesimal: 20:30.15
  156. fixed: 1_230.15
  157. negative infinity: -.inf
  158. not a number: .NaN
  159. # Miscellaneous
  160. ---
  161. null: ~
  162. true: boolean
  163. false: boolean
  164. string: '12345'
  165. # Timestamps
  166. ---
  167. canonical: 2001-12-15T02:59:43.1Z
  168. iso8601: 2001-12-14t21:59:43.10-05:00
  169. spaced: 2001-12-14 21:59:43.10 -5
  170. date: 2002-12-14
  171. # Various explicit tags
  172. ---
  173. not-date: !!str 2002-04-28
  174. picture: !!binary |
  175. R0lGODlhDAAMAIQAAP//9/X
  176. 17unp5WZmZgAAAOfn515eXv
  177. Pz7Y6OjuDg4J+fn5OTk6enp
  178. 56enmleECcgggoBADs=
  179. application specific tag: !something |
  180. The semantics of the tag
  181. above may be different for
  182. different documents.
  183. # Global tags
  184. %TAG ! tag:clarkevans.com,2002:
  185. --- !shape
  186. # Use the ! handle for presenting
  187. # tag:clarkevans.com,2002:circle
  188. - !circle
  189. center: &ORIGIN {x: 73, y: 129}
  190. radius: 7
  191. - !line
  192. start: *ORIGIN
  193. finish: { x: 89, y: 102 }
  194. - !label
  195. start: *ORIGIN
  196. color: 0xFFEEBB
  197. text: Pretty vector drawing.
  198. # Unordered sets
  199. --- !!set
  200. # sets are represented as a
  201. # mapping where each key is
  202. # associated with the empty string
  203. ? Mark McGwire
  204. ? Sammy Sosa
  205. ? Ken Griff
  206. # Ordered mappings
  207. --- !!omap
  208. # ordered maps are represented as
  209. # a sequence of mappings, with
  210. # each mapping having one key
  211. - Mark McGwire: 65
  212. - Sammy Sosa: 63
  213. - Ken Griffy: 58
  214. # Full length example
  215. --- !<tag:clarkevans.com,2002:invoice>
  216. invoice: 34843
  217. date : 2001-01-23
  218. bill-to: &id001
  219. given : Chris
  220. family : Dumars
  221. address:
  222. lines: |
  223. 458 Walkman Dr.
  224. Suite #292
  225. city : Royal Oak
  226. state : MI
  227. postal : 48046
  228. ship-to: *id001
  229. product:
  230. - sku : BL394D
  231. quantity : 4
  232. description : Basketball
  233. price : 450.00
  234. - sku : BL4438H
  235. quantity : 1
  236. description : Super Hoop
  237. price : 2392.00
  238. tax : 251.42
  239. total: 4443.52
  240. comments:
  241. Late afternoon is best.
  242. Backup contact is Nancy
  243. Billsmer @ 338-4338.
  244. # Another full-length example
  245. ---
  246. Time: 2001-11-23 15:01:42 -5
  247. User: ed
  248. Warning:
  249. This is an error message
  250. for the log file
  251. ---
  252. Time: 2001-11-23 15:02:31 -5
  253. User: ed
  254. Warning:
  255. A slightly different error
  256. message.
  257. ---
  258. Date: 2001-11-23 15:03:17 -5
  259. User: ed
  260. Fatal:
  261. Unknown variable "bar"
  262. Stack:
  263. - file: TopClass.py
  264. line: 23
  265. code: |
  266. x = MoreObject("345\n")
  267. - file: MoreClass.py
  268. line: 58
  269. code: |-
  270. foo = bar