| 1 |
# Comment |
| 2 |
# I am a comment. Hear me roar. Roar. |
| 3 |
|
| 4 |
# Table |
| 5 |
# Tables (also known as hash tables or dictionaries) are collections of key/value pairs. |
| 6 |
# They appear in square brackets on a line by themselves. |
| 7 |
|
| 8 |
[Table] |
| 9 |
|
| 10 |
key = "value" # Yeah, you can do this. |
| 11 |
|
| 12 |
# Nested tables are denoted by table names with dots in them. Name your tables whatever crap you please, just don't use #, ., [ or ]. |
| 13 |
|
| 14 |
[dog.tater] |
| 15 |
type = "pug" |
| 16 |
|
| 17 |
# You don't need to specify all the super-tables if you don't want to. TOML knows how to do it for you. |
| 18 |
|
| 19 |
# [x] you |
| 20 |
# [x.y] don't |
| 21 |
# [x.y.z] need these |
| 22 |
[x.y.z.w] # for this to work |
| 23 |
|
| 24 |
# String |
| 25 |
# There are four ways to express strings: basic, multi-line basic, literal, and multi-line literal. |
| 26 |
# All strings must contain only valid UTF-8 characters. |
| 27 |
|
| 28 |
[String] |
| 29 |
basic = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF." |
| 30 |
|
| 31 |
[String.Multiline] |
| 32 |
|
| 33 |
# The following strings are byte-for-byte equivalent: |
| 34 |
key1 = "One\nTwo" |
| 35 |
key2 = """One\nTwo""" |
| 36 |
key3 = """ |
| 37 |
One |
| 38 |
Two""" |
| 39 |
|
| 40 |
[String.Multilined.Singleline] |
| 41 |
|
| 42 |
# The following strings are byte-for-byte equivalent: |
| 43 |
key1 = "The quick brown fox jumps over the lazy dog." |
| 44 |
|
| 45 |
key2 = """ |
| 46 |
The quick brown \ |
| 47 |
|
| 48 |
|
| 49 |
fox jumps over \ |
| 50 |
the lazy dog.""" |
| 51 |
|
| 52 |
key3 = """\ |
| 53 |
The quick brown \ |
| 54 |
fox jumps over \ |
| 55 |
the lazy dog.\ |
| 56 |
""" |
| 57 |
|
| 58 |
[String.Literal] |
| 59 |
|
| 60 |
# What you see is what you get. |
| 61 |
winpath = 'C:\Users\nodejs\templates' |
| 62 |
winpath2 = '\\ServerX\admin$\system32\' |
| 63 |
quoted = 'Tom "Dubs" Preston-Werner' |
| 64 |
regex = '<\i\c*\s*>' |
| 65 |
|
| 66 |
|
| 67 |
[String.Literal.Multiline] |
| 68 |
|
| 69 |
regex2 = '''I [dw]on't need \d{2} apples''' |
| 70 |
lines = ''' |
| 71 |
The first newline is |
| 72 |
trimmed in raw strings. |
| 73 |
All other whitespace |
| 74 |
is preserved. |
| 75 |
''' |
| 76 |
|
| 77 |
# Integer |
| 78 |
# Integers are whole numbers. Positive numbers may be prefixed with a plus sign. |
| 79 |
# Negative numbers are prefixed with a minus sign. |
| 80 |
|
| 81 |
[Integer] |
| 82 |
key1 = +99 |
| 83 |
key2 = 42 |
| 84 |
key3 = 0 |
| 85 |
key4 = -17 |
| 86 |
|
| 87 |
# Float |
| 88 |
# A float consists of an integer part (which may be prefixed with a plus or minus sign) |
| 89 |
# followed by a fractional part and/or an exponent part. |
| 90 |
|
| 91 |
[Float.fractional] |
| 92 |
|
| 93 |
# fractional |
| 94 |
key1 = +1.0 |
| 95 |
key2 = 3.1415 |
| 96 |
key3 = -0.01 |
| 97 |
|
| 98 |
[Float.exponent] |
| 99 |
|
| 100 |
# exponent |
| 101 |
#key1 = 5e+22 |
| 102 |
#key2 = 1e6 |
| 103 |
#key3 = -2E-2 |
| 104 |
|
| 105 |
[Float.both] |
| 106 |
|
| 107 |
# both |
| 108 |
#key = 6.626e-34 |
| 109 |
|
| 110 |
# Boolean |
| 111 |
# Booleans are just the tokens you're used to. Always lowercase. |
| 112 |
|
| 113 |
[Booleans] |
| 114 |
True = true |
| 115 |
False = false |
| 116 |
|
| 117 |
# Datetime |
| 118 |
# Datetimes are RFC 3339 dates. |
| 119 |
|
| 120 |
[Datetime] |
| 121 |
key1 = 1979-05-27T07:32:00Z |
| 122 |
#key2 = 1979-05-27T00:32:00-07:00 |
| 123 |
#key3 = 1979-05-27T00:32:00.999999-07:00 |
| 124 |
|
| 125 |
# Array |
| 126 |
# Arrays are square brackets with other primitives inside. Whitespace is ignored. Elements are separated by commas. Data types may not be mixed. |
| 127 |
|
| 128 |
[Array] |
| 129 |
key1 = [ 1, 2, 3 ] |
| 130 |
key2 = [ "red", "yellow", "green" ] |
| 131 |
key3 = [ [ 1, 2 ], [3, 4, 5] ] |
| 132 |
key4 = [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok |
| 133 |
|
| 134 |
#Arrays can also be multiline. So in addition to ignoring whitespace, arrays also ignore newlines between the brackets. |
| 135 |
# Terminating commas are ok before the closing bracket. |
| 136 |
|
| 137 |
key5 = [ |
| 138 |
1, 2, 3 |
| 139 |
] |
| 140 |
key6 = [ |
| 141 |
1, |
| 142 |
2, # this is ok |
| 143 |
] |
| 144 |
|
| 145 |
# Array of Tables |
| 146 |
# These can be expressed by using a table name in double brackets. |
| 147 |
# Each table with the same double bracketed name will be an element in the array. |
| 148 |
# The tables are inserted in the order encountered. |
| 149 |
|
| 150 |
[[products]] |
| 151 |
name = "Hammer" |
| 152 |
sku = 738594937 |
| 153 |
|
| 154 |
[[products]] |
| 155 |
|
| 156 |
[[products]] |
| 157 |
name = "Nail" |
| 158 |
sku = 284758393 |
| 159 |
color = "gray" |
| 160 |
|
| 161 |
|
| 162 |
# You can create nested arrays of tables as well. |
| 163 |
|
| 164 |
[[fruit]] |
| 165 |
name = "apple" |
| 166 |
|
| 167 |
[fruit.physical] |
| 168 |
color = "red" |
| 169 |
shape = "round" |
| 170 |
|
| 171 |
[[fruit.variety]] |
| 172 |
name = "red delicious" |
| 173 |
|
| 174 |
[[fruit.variety]] |
| 175 |
name = "granny smith" |
| 176 |
|
| 177 |
[[fruit]] |
| 178 |
name = "banana" |
| 179 |
|
| 180 |
[[fruit.variety]] |
| 181 |
name = "plantain" |
| 182 |
|