################################################################################
## Comment
# Speak your mind with the hash symbol. They go from the symbol to the end of
# the line.
################################################################################
## Table
# Tables (also known as hash tables or dictionaries) are collections of
# key/value pairs. They appear in square brackets on a line by themselves.
[]
= "value" # Yeah, you can do this.
# Nested tables are denoted by table names with dots in them. Name your tables
# whatever crap you please, just don't use #, ., [ or ].
[]
= "another value"
# You don't need to specify all the super-tables if you don't want to. TOML
# knows how to do it for you.
# [x] you
# [x.y] don't
# [x.y.z] need these
[] # for this to work
################################################################################
## Inline Table
# Inline tables provide a more compact syntax for expressing tables. They are
# especially useful for grouped data that can otherwise quickly become verbose.
# Inline tables are enclosed in curly braces `{` and `}`. No newlines are
# allowed between the curly braces unless they are valid within a value.
[]
= { = "Tom", = "Preston-Werner" }
= { = 1, = 2 }
################################################################################
## String
# There are four ways to express strings: basic, multi-line basic, literal, and
# multi-line literal. All strings must contain only valid UTF-8 characters.
[]
= "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
[]
# The following strings are byte-for-byte equivalent:
= "One\nTwo"
= """One\nTwo"""
= """
One
Two"""
[]
# The following strings are byte-for-byte equivalent:
= "The quick brown fox jumps over the lazy dog."
= """
The quick brown \
fox jumps over \
the lazy dog."""
= """\
The quick brown \
fox jumps over \
the lazy dog.\
"""
[]
# What you see is what you get.
= 'C:\Users\nodejs\templates'
= '\\ServerX\admin$\system32\'
= 'Tom "Dubs" Preston-Werner'
= '<\i\c*\s*>'
[]
= '''I [dw]on't need \d{2} apples'''
= '''
The first newline is
trimmed in raw strings.
All other whitespace
is preserved.
'''
################################################################################
## Integer
# Integers are whole numbers. Positive numbers may be prefixed with a plus sign.
# Negative numbers are prefixed with a minus sign.
[]
= +99
= 42
= 0
= -17
[]
# For large numbers, you may use underscores to enhance readability. Each
# underscore must be surrounded by at least one digit.
= 1_000
= 5_349_221
= 1_2_3_4_5 # valid but inadvisable
################################################################################
## Float
# A float consists of an integer part (which may be prefixed with a plus or
# minus sign) followed by a fractional part and/or an exponent part.
[]
= +1.0
= 3.1415
= -0.01
[]
[]
[]
################################################################################
## Boolean
# Booleans are just the tokens you're used to. Always lowercase.
[]
= true
= false
################################################################################
## Datetime
# Datetimes are RFC 3339 dates.
[]
#key1 = 1979-05-27T07:32:00Z
#key2 = 1979-05-27T00:32:00-07:00
#key3 = 1979-05-27T00:32:00.999999-07:00
################################################################################
## Array
# Arrays are square brackets with other primitives inside. Whitespace is
# ignored. Elements are separated by commas. Data types may not be mixed.
[]
= [ 1, 2, 3 ]
= [ "red", "yellow", "green" ]
= [ [ 1, 2 ], [3, 4, 5] ]
= [ [ 1, 2 ], ["a", "b", "c"] ] # this is ok
# Arrays can also be multiline. So in addition to ignoring whitespace, arrays
# also ignore newlines between the brackets. Terminating commas are ok before
# the closing bracket.
= [
1, 2, 3
]
= [
1,
2, # this is ok
]
################################################################################
## Array of Tables
# These can be expressed by using a table name in double brackets. Each table
# with the same double bracketed name will be an element in the array. The
# tables are inserted in the order encountered.
[[]]
= "Hammer"
= 738594937
[[]]
[[]]
= "Nail"
= 284758393
= "gray"
# You can create nested arrays of tables as well.
[[]]
= "apple"
[]
= "red"
= "round"
[[]]
= "red delicious"
[[]]
= "granny smith"
[[]]
= "banana"
[[]]
= "plantain"