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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711
|
use strict;
use lib -e 't' ? 't' : 'test';
use TestYAML tests => 52;
run_load_passes();
__DATA__
===
+++ yaml
- Mark McGwire
- Sammy Sosa
- Ken Griffey
===
+++ yaml
hr: 65
avg: 0.278
rbi: 147
===
+++ yaml
american:
- Boston Red Sox
- Detroit Tigers
- New York Yankees
- Texas Rangers
national:
- New York Mets
- Chicago Cubs
- Atlanta Braves
- Montreal Expos
===
+++ yaml
-
name: Mark McGwire
hr: 65
avg: 0.278
rbi: 147
-
name: Sammy Sosa
hr: 63
avg: 0.288
rbi: 141
===
+++ yaml
?
- New York Yankees
- Atlanta Braves
:
- 2001-07-02
- 2001-08-12
- 2001-08-14
?
- Detroit Tigers
- Chicago Cubs
:
- 2001-07-23
===
+++ yaml
invoice: 34843
date : 2001-01-23
bill-to:
given : Chris
family : Dumars
product:
- quantity: 4
desc : Basketball
- quantity: 1
desc : Super Hoop
===
+++ yaml
---
name: Mark McGwire
hr: 65
avg: 0.278
rbi: 147
---
name: Sammy Sosa
hr: 63
avg: 0.288
rbi: 141
===
+++ yaml
# Ranking of players by
# season home runs.
---
- Mark McGwire
- Sammy Sosa
- Ken Griffey
===
+++ yaml
#hr: # Home runs
# # 1998 record
# - Mark McGwire
# - Sammy Sosa
#rbi: # Runs batted in
# - Sammy Sosa
# - Ken Griffey
===
+++ yaml
hr:
- Mark McGwire
# Name "Sammy Sosa" scalar SS
- &SS Sammy Sosa
rbi:
# So it can be referenced later.
- *SS
- Ken Griffey
===
+++ yaml
--- >
Mark McGwire's
year was crippled
by a knee injury.
===
+++ yaml
--- |
\/|\/|
/ | |_
===
+++ yaml
--- >-
Sosa completed
another fine
season.
===
+++ yaml
#name: Mark McGwire
#occupation: baseball player
#comments: Mark set a major
# league home run
# record in 1998.
===
+++ yaml
years: "1998\t1999\t2000\n"
msg: "Sosa did fine. \u263A"
===
+++ yaml
- ' \/|\/| '
- ' / | |_ '
===
+++ yaml
- [ name , hr , avg ]
- [ Mark McGwire , 65 , 0.278 ]
- [ Sammy Sosa , 63 , 0.288 ]
===
+++ yaml
#Mark McGwire: {hr: 65, avg: 0.278}
#Sammy Sosa: {hr: 63,
# avg: 0.288}
===
+++ yaml
invoice: 34843
date : 2001-01-23
buyer:
given : Chris
family : Dumars
product:
- Basketball: 4
- Superhoop: 1
===
+++ yaml
#invoice: !int|dec 34843
#date : !time 2001-01-23
#buyer: !map
# given : !str Chris
# family : !str Dumars
#product: !seq
# - !str Basketball: !int 4
# - !str Superhoop: !int 1
===
+++ yaml
#invoice: !str 34843
#date : !str 2001-01-23
===
+++ yaml
#--- !clarkevans.com/schedule/^entry
#who: Clark C. Evans
#when: 2001-11-18
#hours: !^hours 3
#description: >
# Wrote up these examples
# and learned a lot about
# baseball statistics.
===
+++ yaml
#--- !clarkevans.com/graph/^shape
#- !^circle
# center: &ORIGIN {x: 73, y: 129}
# radius: 7
#- !^line [23, 32, 300, 200]
#- !^text
# center: *ORIGIN
# color: 0x02FDBA
===
+++ yaml
--- !clarkevans.com/^invoice
invoice: 34843
date : 2001-01-23
bill-to: &id001
given : Chris
family : Dumars
address:
lines: |
458 Walkman Dr.
Suite #292
city : Royal Oak
state : MI
postal : 48046
ship-to: *id001
product:
- sku : BL394D
quantity : 4
description : Basketball
price : 450.00
- sku : BL4438H
quantity : 1
description : Super Hoop
price : 2392.00
tax : 251.42
total: 4443.52
comments: >
Late afternoon is best.
Backup contact is Nancy
Billsmer @ 338-4338.
===
+++ yaml
---
Date: 2001-11-23
Time: 15:01:42
User: ed
Warning: >
This is an error message
for the log file
---
Date: 2001-11-23
Time: 15:02:31
User: ed
Warning: >
A slightly different error
message.
---
Date: 2001-11-23
Time: 15:03:17
User: ed
Fatal: >
Unknown variable "bar"
Stack:
- file: TopClass.py
line: 23
code: |
x = MoreObject("345\n")
- file: MoreClass.py
line: 58
code: |
foo = bar
===
+++ yaml
###################################
## These are four throwaway comment
#
## lines (the second line is empty).
#this: | # Comments may trail lines.
# contains three lines of text.
# The third one starts with a
# # character. This isn't a comment.
#
## These are four throwaway comment
## lines (the first line is empty).
###################################
===
+++ yaml
--- >
This YAML stream contains a single text value.
The next stream is a log file - a sequence of
log entries. Adding an entry to the log is a
simple matter of appending it at the end.
===
+++ yaml
---
at: 2001-08-12T09:25:00.00
type: GET
HTTP: '1.0'
url: '/index.html'
---
at: 2001-08-12T09:25:10.00
type: GET
HTTP: '1.0'
url: '/toc.html'
===
+++ yaml
## The following is a sequence of three documents.
## The first contains an empty mapping, the second
## an empty sequence, and the last an empty string.
#--- {}
#--- [ ]
#--- ''
===
+++ yaml
## All entries in the sequence
## have the same type and value.
#- 10.0
#- !float 10
#- !yaml.org/^float '10'
#- !http://yaml.org/float "\
# 1\
# 0"
===
+++ yaml
## Private types are per-document.
#---
#pool: !!ball
# number: 8
# color: black
#---
#bearing: !!ball
# material: steel
===
+++ yaml
## 'http://domain.tld/invoice' is some type family.
#invoice: !domain.tld/^invoice
# # 'seq' is shorthand for 'http://yaml.org/seq'.
# # This does not effect '^customer' below
# # because it is does not specify a prefix.
# customers: !seq
# # '^customer' is shorthand for the full
# # notation 'http://domain.tld/customer'.
# - !^customer
# given : Chris
# family : Dumars
===
+++ yaml
## It is possible to use XML namespace URIs as
## YAML namespaces. Using the ancestor's URI
## allows specifying it only once. The $ separates
## between the XML namespace URI and the tag name.
#doc: !http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd$^html
# - !^body
# - !^p This is an HTML paragraph.
===
+++ yaml
anchor : &A001 This scalar has an anchor.
override : &A001 >
The alias node below is a
repeated use of this value.
alias : *A001
===
+++ yaml
#empty: []
#in-line: [ one, two, three # May span lines,
# , four, # indentation is
# five ] # mostly ignored.
#nested:
# - First item in top sequence
# -
# - Subordinate sequence entry
# - >
# A multi-line
# sequence entry
# - Sixth item in top sequence
===
+++ yaml
#empty: {}
#in-line: { one: 1, two: 2 }
#spanning: { one: 1,
# two: 2 }
#nested:
# first : First entry
# second:
# key: Subordinate mapping
# third:
# - Subordinate sequence
# - { }
# - Previous mapping is empty.
# - A key: value pair in a sequence.
# A second: key:value pair.
# - The previous entry is equal to the following one.
# -
# A key: value pair in a sequence.
# A second: key:value pair.
# !float 12 : This key is a float.
# ? >
# ?
# : This key had to be protected.
# "\a" : This key had to be escaped.
# ? >
# This is a
# multi-line
# folded key
# : Whose value is
# also multi-line.
# ?
# - This key
# - is a sequence
# :
# - With a sequence value.
# ?
# This: key
# is a: mapping
# :
# with a: mapping value.
===
+++ yaml
empty: |
detected: |
The \ ' " characters may be
freely used. Leading white
space is significant.
All line breaks are significant,
including the final one. Thus
this value contains one empty
line and ends with a line break,
but does not start with one.
# Comments may follow a nested
# scalar value. They must be
# less indented.
# Explicit indentation must
# be given in all the three
# following cases.
leading spaces: |2
This value starts with four
spaces. It ends with one line
break and an empty comment line.
leading line break: |2
This value starts with
a line break and ends
with one.
leading comment indicator: |2
# first line starts with a
#. This value does not start
with a line break but ends
with one.
# Explicit indentation may
# also be given when it is
# not required.
redundant: |2
This value is indented 2 spaces.
stripped: |-
This contains no newline.
kept: |+
This contains two newlines.
# Comments may follow.
===
+++ yaml
#empty: >
#detected: >
# Line feeds are converted
# to spaces, so this value
# contains no line breaks
# except for the final one.
#
#explicit: >2
#
# An empty line, either
# at the start or in
# the value:
#
# Is interpreted as a
# line break. Thus this
# value contains three
# line breaks.
#
#stripped: >-1
# This starts with a space
# and contains no newline.
#
#kept: >1+
# This starts with a space
# and contains two newlines.
#
#indented: >
# This is a folded
# paragraph followed
# by a list:
# * first entry
# * second entry
# Followed by another
# folded paragraph,
# another list:
#
# * first entry
#
# * second entry
#
# And a final folded
# paragraph.
#block: | # Equal to above.
# This is a folded paragraph followed by a list:
# * first entry
# * second entry
# Followed by another folded paragraph and list:
#
# * first entry
#
# * second entry
#
# And a final folded paragraph.
#
## Explicit comments may follow
## but must be less indented.
===
+++ yaml
#empty: ''
#second: '! : \ etc. can be used freely.'
#third: 'a single quote '' must be escaped.'
#span: 'this contains
# six spaces
#
# and one
# line break'
===
+++ yaml
#empty: ""
#second: "! : etc. can be used freely."
#third: "a \" or a \\ must be escaped."
#fourth: "this value ends with an LF.\n"
#span: "this contains
# four \
# spaces"
===
+++ yaml
#first: There is no unquoted empty string.
#second: 12 ## This is an integer.
#third: !str 12 ## This is a string.
#span: this contains
# six spaces
#
# and one
# line break
#indicators: this has no comments.
# #foo and bar# are
# all text.
#in-line: [ can span
# lines, # comment
# like
# this ]
#note: { one-line keys: but
# multi-line values }
===
+++ yaml
## The following are equal seqs
## with different identities.
#in-line: [ one, two ]
#spanning: [ one,
# two: ]
#nested:
# - one
# - two
===
+++ yaml
# The following are equal maps
# with different identities.
in-line: { one: 1, two: 2 }
nested:
one: 1
two: 2
===
+++ yaml
#- 12 # An integer
## The following scalars
## are loaded to the
## string value '1' '2'.
#- !str 12
#- '12'
#- "12"
#- "\
# 1\
# 2\
# "
===
+++ yaml
#canonical: ~
#verbose: (null)
#sparse:
# - ~
# - Second entry.
# - (nil)
# - This sequence has 4 entries, two with values.
#three: >
# This mapping has three keys,
# only two with values.
===
+++ yaml
#canonical: -
#logical: (true)
#informal: (no)
===
+++ yaml
#canonical: 12345
#decimal: +12,345
#octal: 014
#hexadecimal: 0xC
===
+++ yaml
#canonical: 1.23015e+3
#exponential: 12.3015e+02
#fixed: 1,230.15
#negative infinity: (-inf)
#not a number: (NaN)
===
+++ yaml
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 -05:00
date (noon UTC): 2002-12-14
===
+++ yaml
#canonical: !binary "\
# R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOf\
# n515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaW\
# NjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++\
# f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUg\
# d2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuN\
# AFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84Bww\
# EeECcgggoBADs="
#base64: !binary |
# R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOf
# n515eXvPz7Y6OjuDg4J+fn5OTk6enp56enmlpaW
# NjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++
# f/++f/++f/++f/++f/++f/++f/++SH+Dk1hZGUg
# d2l0aCBHSU1QACwAAAAADAAMAAAFLCAgjoEwnuN
# AFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84Bww
# EeECcgggoBADs=
#description: >
# The binary value above is a tiny arrow
# encoded as a gif image.
===
+++ yaml
## Old schema
#---
#link with:
# - library1.dll
# - library2.dll
#
## New schema
#---
#link with:
# - = : library1.dll
# version: 1.2
# - = : library2.dll
# version: 2.1
===
+++ yaml
#"!": These three keys
#"&": had to be quoted
#"=": and are normal strings.
## NOTE: the following encoded node
## should NOT be serialized this way.
#encoded node :
# !special '!' : '!type'
# !special '&' : 12
# = : value
## The proper way to serialize the
## above structure is as follows:
#node : !!type &12 value
|