toml README

The project's README from github.com/toml-lang/toml. As one markdown file: README.md.

TOML logo

TOML

Tom's Obvious, Minimal Language.

By Tom Preston-Werner, Pradyun Gedam, et al.

This repository contains the in-development version of the TOML specification. You can find the released versions at https://toml.io.

Objectives

TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics. TOML is designed to map unambiguously to a hash table. TOML should be easy to parse into data structures in a wide variety of languages.

Example

# This is a TOML document.

title = "TOML Example"

[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates

[database]
server = "192.168.1.1"
ports = [ 8000, 8001, 8002 ]
connection_max = 5000
enabled = true

[servers]

  # Indentation (tabs and/or spaces) is allowed but not required
  [servers.alpha]
  ip = "10.0.0.1"
  dc = "eqdc10"

  [servers.beta]
  ip = "10.0.0.2"
  dc = "eqdc10"

[clients]
data = [ ["gamma", "delta"], [1, 2] ]

# Line breaks are OK when inside arrays
hosts = [
  "alpha",
  "omega"
]

Comparison with Other Formats

TOML shares traits with other file formats used for application configuration and data serialization, such as YAML and JSON. TOML and JSON both are simple and use ubiquitous data types, making them easy to code for or parse with machines. TOML and YAML both emphasize human readability features, like comments that make it easier to understand the purpose of a given line. TOML differs in combining these, allowing comments (unlike JSON) but preserving simplicity (unlike YAML).

Because TOML is explicitly intended as a configuration file format, parsing it is easy, but it is not intended for serializing arbitrary data structures. TOML always has a hash table at the top level of the file, which can easily have data nested inside its keys, but it doesn't permit top-level arrays or floats, so it cannot directly serialize some data. There is also no standard identifying the start or end of a TOML file, which can complicate sending it through a stream. These details must be negotiated on the application layer.

INI files are frequently compared to TOML for their similarities in syntax and use as configuration files. However, there is no standardized format for INI and they do not gracefully handle more than one or two levels of nesting.

Further reading:

Get Involved

Documentation, bug reports, pull requests, and all other contributions are welcome!

Wiki

We have an Official TOML Wiki that catalogs the following:

Please take a look if you'd like to view or add to that list. Thanks for being a part of the TOML community!

toml (toml-lang/toml)

Searching Database…

20.6K ·GitHub
这是什么?TOML(Tom's Obvious, Minimal Language,意为“Tom 的显而易见的极简语言”)是一种极简的配置文件格式,设计目标是让人一眼就能读懂,语义足够直观,可以干净地映射到哈希表上。这个仓库保存的是仍在开发中的 TOML 规范本身。
那这是个工具还是库?我看到的到底是什么?都不是——这个仓库是规范,也就是定义语法的文档。具体的软件是另外的 TOML 库,为很多编程语言分别编写。
那我要怎么开始使用 TOML?这个仓库里没有什么可安装的——TOML 是一种文本格式,你直接用手写,再用适合你所使用语言的库来解析。TOML 官方 Wiki 是入门起点:上面列出了各种实现、编辑器支持和转换工具。
TOML 有哪些做不到的事?有两点需要知道:顶层永远是一个哈希表——顶层不能是数组或浮点数——所以有些数据无法直接序列化;另外文件没有标准的起止标记,这给流式处理带来了麻烦。
既然已经有 JSON 和 YAML 了,为什么还要创建 TOML?因为它们没有哪一个是两者兼备的:JSON 简单但不允许写注释,YAML 可读但复杂。TOML 的设计目标就是让应用配置同时拥有这两个优点。
配置为什么不用 INI 文件就行了?INI 看起来很相似,但没有标准化的格式,而且嵌套超过一两层就会很难处理——TOML 是有标准的,并且能把数据嵌套在键下面。
TOML 规范还在不断演进吗?是的——这个仓库托管的是开发中的规范版本,而稳定的已发布版本会单独发布,所以改动会先落在这里。
TOML 真的是以一个叫 Tom 的人命名的吗?是的——它是 Tom's Obvious, Minimal Language 的缩写,以创建者 Tom Preston-Werner 命名;如今由 Pradyun Gedam 和其他贡献者维护这份规范。
Creator
toml-lang
Size
2.4 MB
Stars
20.6K
Age
13y
Commits · 90 Days