TOML file example

This tutorial covers toml example file ..

TOML Syntax

TOML file contains the documents each document contains the syntax specified as per TOML supported rules. Each document or line contains key and value pairs Following is the syntax

key= “value”

key and value pair are separated by equal sign and value must be double quotes Key of type string which accepts characters/ascii codes/numbers/dashes and underscore

Example file

# this is sample file

following are valid keys
key="value"
test_key="value"
956="value"
key-1="value"
 key = "value" #keys with spaces are allowed
"key" = "value" # quoted keys are valid
dev.db.url="localhost" # keys contains dotted symbol are allowed for grouping

Invalid keys

  • value without keys are not allowed, for example, =“without key”
  • duplicate keys are not allowed

value types

values accepts of types string,integer,Float,Boolean,Date types,Array and tables only

TOML data key and value pair rules

  • value must be enclosed in double quotes
  • key and value pair declared in single line only
  • spaces before or after key and value pairs are ignored
  • key is of type string and value supports limited values of different types
  • new line must be followed by key and value pairs in a single line
  • if value is not declared, default value is INVALID

comments declaration

Like a programming languages, It supports comments, Comments are usually ignored by runtime interpreters. Comments are useful to specify the explainaton about the configuration data. Hash symbol is used for specifying comments at the starting character in the line

\# this is comment
environment="development"

It supports single line comments and does not supports multi line comments if you want to specify the multiple lines, each line is marked with # symbol

Prev