TOML
TOML(Tom 的明显、最小化语言)是面向配置的格式,用表与键值对表示数据,语义明确且无隐式类型推断。
用途
提供比 YAML 更明确、比 JSON 更适合配置的格式,避免 YAML 的类型推断陷阱。
机制
用 [section] 声明表,key = value 声明键值。支持字符串、整数、浮点、布尔、日期、数组与内联表。无引用、无多文档,类型显式。Rust Cargo.toml 与 Python pyproject.toml 为主要用户。
用例
- Rust Cargo.toml 清单
- Python pyproject.toml 项目配置
- 静态站点生成器配置
- 工具链配置
示例
- 输入
[owner] name = "Ada"输出The table {owner:{name:"Ada"}}Explicit types
常见错误
- Expecting TOML but writing YAML-style indentation
- TOML uses table headers, not indentation