.toml
Code
TOML(Tom 的浅显极简语言)
TOML 是一种为清晰和简洁而设计的配置文件格式。它可以无歧义地映射到哈希表,易于人类读写。TOML 是 Rust 的 Cargo.toml 和 Python 的 pyproject.toml 的标准格式。
MIME 类型
application/toml
类型
文本
压缩
无损
优点
- + Unambiguous — no implicit type coercion unlike YAML
- + Native datetime support without quoting
- + Simple, flat structure that maps directly to hash tables
- + Standard in Rust and Python ecosystems
缺点
- − Deeply nested data structures become verbose
- − Less widespread tool support compared to JSON and YAML
- − No standard way to represent null values
何时使用 .TOML
将 TOML 用于配置文件——特别是在 Rust(Cargo.toml)和 Python(pyproject.toml)生态系统中。适用于需要无歧义解析的场景。
技术细节
TOML 使用键值对、表(方括号中的节)、表数组(双方括号)以及原生类型值,包括日期时间、整数、浮点数、布尔值和字符串。缩进不具有意义。
历史
Tom Preston-Werner(GitHub 联合创始人)于 2013 年创建了 TOML,作为 YAML 和 JSON 配置文件的极简替代方案。经过广泛的社区反馈,TOML 1.0 于 2021 年 1 月发布。