← 返回
内容创作
中文
YAML
Write valid YAML that parses predictably across languages and versions.
编写可跨语言和版本可预测解析的有效 YAML。
ivangdavila
内容创作
clawhub
v1.0.0 1 版本 99707.7 Key: 无需
#latest
概述
Type Coercion Traps
yes, no, on, off, true, false → boolean; quote if literal string: "yes"NO (Norway country code) → false in YAML 1.1; always quote country codes1.0 → float, 1 → int; quote version numbers: "1.0"010 → octal (8) in YAML 1.1; quote or use 0o10 explicitlynull, ~, empty value → null; quote if literal: "null", "~".inf, -.inf, .nan → special floats; quote if literal strings
Indentation
- Spaces only—tabs are forbidden and cause parse errors
- Consistent indent width required within document—2 spaces conventional
- Sequence items
- count as indentation—nested content aligns after the space
Strings
- Colon followed by space
: triggers key-value—quote strings containing : # starts comment unless quoted—quote strings with #- Leading/trailing spaces stripped from unquoted strings—quote to preserve
- Quote strings starting with
@, ` `, *, &, !, |, >, {, [, %`
Multiline Strings
| literal block preserves newlines; > folded block joins lines with spaces- Trailing newline:
|- and >- strip final newline; |+ and >+ keep trailing blank lines - Indentation of first content line sets the block indent—be consistent
Structure
- Duplicate keys: YAML spec says last wins, but some parsers error—avoid duplicates
- Anchors
&name and aliases *name reduce repetition—but aliases can't override anchor values - Document separator
--- starts new document; ... ends document—useful in streams - Empty documents between
--- markers are valid but often unintended
Comments
# only valid at line start or after whitespace—key:value#comment has no comment- No inline comments after multiline block scalars—comment applies to next line
- No multi-line comment syntax—each line needs
#
Compatibility
- YAML 1.1 vs 1.2: boolean words (
yes/no), octal syntax differ—know which version parser uses - JSON is valid YAML 1.2—but YAML features (anchors, multiline) don't round-trip to JSON
- Some parsers limit nesting depth or file size—test with expected data scale
版本历史
共 1 个版本
-
v1.0.0
当前
2026-03-28 22:36 安全 安全
安全检测
腾讯云安全 (Sanbu)
安全,无风险
查看报告
🔗 相关推荐
content-creation
biostartechnology
消除AI写作痕迹,使文本更自然真实。基于维基百科"AI写作特征"指南,识别并修正夸张象征、宣传用语、肤浅-ing分析、模糊归因、破折号滥用、三项排比、AI词汇、负面平行结构及冗长连接词等模式。
★ 857
📥 199,385
ai-intelligence
ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,352
📥 317,816
content-creation
fly0pants
广告情报与应用数据分析助手,支持搜索广告素材、分析应用排名、下载量、收入及市场洞察,用于广告素材和竞品分析。
★ 295
📥 136,426