| 1 | <h2>Null and Boolean</h2> |
| 2 | <pre><code>--- |
| 3 | A null: null |
| 4 | A null: ~ |
| 5 | Also a null: # Empty |
| 6 | Not a null: "" |
| 7 | Booleans: [ true, True, false, FALSE ] |
| 8 | </code></pre> |
| 9 | |
| 10 | <h2>Numbers and timestamps</h2> |
| 11 | <pre><code>--- |
| 12 | Integers: [ 0, -0, 3, 0o7, 0x3A, -19 ] |
| 13 | Floats: [ 0., -0.0, .5, 12e03, +12e03, -2E+05 ] |
| 14 | Also floats: [ .inf, -.Inf, +.INF, .NAN ] |
| 15 | Timestamps: |
| 16 | canonical: 2001-12-15T02:59:43.1Z |
| 17 | iso8601: 2001-12-14t21:59:43.10-05:00 |
| 18 | spaced: 2001-12-14 21:59:43.10 -5 |
| 19 | date: 2002-12-14 |
| 20 | times: |
| 21 | - 10:53 |
| 22 | - 10:53:20.53 |
| 23 | </code></pre> |
| 24 | |
| 25 | <h2>Strings</h2> |
| 26 | <pre><code>--- |
| 27 | product: High Heeled "Ruby" Slippers |
| 28 | description: "Putting on these \"slippers\" is easy." |
| 29 | address: |
| 30 | city: East Centerville |
| 31 | street: !!str | |
| 32 | 123 Tornado Alley |
| 33 | Suite 16 |
| 34 | |
| 35 | specialDelivery: > |
| 36 | Follow the Yellow Brick |
| 37 | Road to the Emerald City. |
| 38 | #Pay no attention to the |
| 39 | man behind the curtain. |
| 40 | </code></pre> |
| 41 | |
| 42 | <h2>Sequences and maps</h2> |
| 43 | <pre><code>--- |
| 44 | - Casablanca |
| 45 | - North by Northwest |
| 46 | - { |
| 47 | name: John Smith, age: 33} |
| 48 | - name: Mary Smith |
| 49 | age: 27 |
| 50 | --- |
| 51 | "name": John Smith |
| 52 | age: 33 |
| 53 | men: [ John Smith, |
| 54 | "Bill Jones" ] |
| 55 | women: |
| 56 | - Mary Smith |
| 57 | - "Susan Williams" |
| 58 | </code></pre> |
| 59 | |
| 60 | <h2>Tags</h2> |
| 61 | <pre><code>--- |
| 62 | !!map { |
| 63 | ? !!str friends: !!seq [ |
| 64 | !!map { |
| 65 | ? !!str "age" |
| 66 | : !!int 33, |
| 67 | ? !!str "name" |
| 68 | : !!str "John Smith", |
| 69 | } |
| 70 | ], |
| 71 | men: |
| 72 | [ !!str "John Smith", !!str "Bill Jones"] |
| 73 | } |
| 74 | </code></pre> |
| 75 | |
| 76 | <h2>Full example</h2> |
| 77 | <pre><code>%YAML 1.2 |
| 78 | --- !<tag:clarkevans.com,2002:invoice> |
| 79 | invoice: 34843 |
| 80 | date : 2001-01-23 |
| 81 | bill-to: &id001 |
| 82 | given : Chris |
| 83 | family : Dumars |
| 84 | address: |
| 85 | lines: | |
| 86 | 458 Walkman Dr. |
| 87 | Suite #292 |
| 88 | city : Royal Oak |
| 89 | state : MI |
| 90 | postal : 48046 |
| 91 | ship-to: |
| 92 | <<: *id001 |
| 93 | product: |
| 94 | - sku : BL394D |
| 95 | quantity : 4 |
| 96 | description : Basketball |
| 97 | price : 450.00 |
| 98 | - sku : BL4438H |
| 99 | quantity : 1 |
| 100 | description : Super Hoop |
| 101 | price : 2392.00 |
| 102 | tax : 251.42 |
| 103 | total: 4443.52 |
| 104 | comments: |
| 105 | Late afternoon is best. |
| 106 | Backup contact is Nancy |
| 107 | </code></pre> |