跳到主要内容
uencoder

Use TOML arrays 和数组的 tables

TOML supports arrays 的 primitives 和 arrays 的 tables. Learn syntax 为 inline arrays, multi-行 arrays, 和 [[表]] arrays 为 structured 数据.

  1. 1

    TOML arrays: inline ([1, 2, 3]) 或 multi-行 (one 元素 per 行具有 trailing comma). 数组的 tables 我们 [[表]] — 每个 occurrence appends 新元素到 数组. 此是 useful 为 lists 的 structured objects (e.g., [[servers]] 具有 name, 主机, 端口).

  2. 2
    TOML 转换器 →

    解析 the TOML file and convert to JSON to verify array structures. Inline arrays become JSON arrays; [[table]] becomes an array of objects. The conversion makes the structure explicit and easy to inspect.

  3. 3
    JSON 格式化器 →

    格式化 the converted JSON to see the array structure clearly. Arrays of tables become arrays of objects — verify the nesting and element count. This is useful for debugging TOML parsing issues.

  4. 4
    toml-convert → json-format

    Use TOML-to-JSON workflow 到解析, 转换, 和格式化在 one 步骤. 此 validates TOML syntax 和 shows 结果结构.

  5. 5

    TOML 数组 syntax: inline = [1, 2, 3], multi-行 = [ 1, 2, 3 ], 数组的 tables = [[product]] name = "" [[product]] name = "B". Mixed-类型 arrays 是允许在 TOML 1.0 但 discouraged. Use arrays 的 tables 为 lists 的配置 objects (servers, endpoints, features).

常见问题

能够 TOML arrays 包含 mixed types?
TOML 1.0 allows mixed-类型 arrays: [1, "two", 真]. However, 此是 discouraged — 它 makes parsing 和 validation harder. Use homogeneous arrays (所有 strings, 所有 integers, 所有 tables) 为 clarity 和类型安全性.
如何数组的 tables 不同从 inline arrays 的 tables?
[[表]] creates 数组的 tables 通过 appending 每个 occurrence. 你能够 also 写入 inline: products = [{name = "", price = 1}, {name = "B", price = 2}]. [[表]] form 是 preferred 为 readability 具有许多 fields; inline 是 fine 为短 entries.

解决此任务的工作流

通过 JSON 比较两份 YAML 配置
将 YAML 配置转换为 JSON,便于对结构化数值进行便于比较的差异对比。
管道
为 URL 传输编码 JSON 载荷
将 JSON 文档准备为 URL 参数:格式化、Base64 编码、再百分号编码——即嵌套参数解码链的精确逆过程。
管道
HJSON 转 JSON 格式化
格式化 HJSON 后转为标准 JSON。
管道
格式化 JSON 并计算完整性校验和
格式化 JSON 文档并计算 CRC32 校验和,以检测后续任何修改。
管道
JSON 格式化并验证
一次性格式化 JSON 以便检视,并验证语法正确。
管道
格式化 JSON 并生成 TypeScript 接口
格式化 JSON 文档,再在一条链中推断出 TypeScript 接口定义。
管道
校验、格式化后将 JSON 转 YAML
将(可能被压缩的)JSON 配置转换为 YAML,在第一个节点捕获语法错误,而非生成细微错误的 YAML。
管道
JSON5 转 JSON 格式化
格式化 JSON5 后转为标准 JSON。
管道
JSONC 转 JSON 格式化
格式化 JSONC 后转为标准 JSON。
管道
解码并格式化 JWT 载荷
解析 JWT 令牌,提取其载荷,并格式化 JSON 以便检视。
管道
解析查询字符串并格式化 JSON
解析查询字符串为键值对后格式化为 JSON。
管道
TOML 转 JSON
将 TOML 配置文件解析为 JSON,供期望 JSON 输入的工具和 API 使用。
管道
TOML 转 JSON 再转 CSV
将 TOML 转为 JSON 再转 CSV。
管道
TOML 转 JSON 再转 YAML
通过 JSON 将 TOML 配置转为 YAML,用于 Kubernetes 或 CI 工具。
管道
经 JSON 将 TOML 转 YAML
将 TOML 配置文件转换为 YAML 格式,以 JSON 作为中间表示。
管道
解码嵌套 URL 参数(Base64 JSON)
将承载 URL 编码 Base64 JSON 的 URL 参数解包为可读的格式化 JSON。
管道
从 YAML 生成 TypeScript 接口
将 YAML 文档转换为 TypeScript 接口定义,以 JSON 作为中间格式。
管道

相关工具