您如何在YAML中阻止评论? [英] How do you do block comments in YAML?
问题描述
如何在YAML中注释行块?
How do I comment a block of lines in YAML?
推荐答案
YAML支持内联注释,但不支持块注释。
YAML supports inline comments, but does not support block comments.
来自维基百科:
注释以数字符号(
#
)开头,可以在一行的任何地方开始,并继续到行尾
Comments begin with the number sign (
#
), can start anywhere on a line, and continue until the end of the line
与JSON的比较,也来自维基百科:
A comparison with JSON, also from Wikipedia:
语法上的区别微妙而很少在实践中出现:JSON允许扩展字符集(如UTF-32),YAML要求在逗号,等号和冒号等分隔符后留一个空格,而JSON则不允许,并且一些非标准的JSON实现将语法扩展为包括Java语言的
/ * ... * /
注释。处理此类极端情况可能需要在将JSON解析为嵌入式YAML之前对JSON进行少量预处理。
The syntax differences are subtle and seldom arise in practice: JSON allows extended charactersets like UTF-32, YAML requires a space after separators like comma, equals, and colon while JSON does not, and some non-standard implementations of JSON extend the grammar to include Javascript's
/* ... */
comments. Handling such edge cases may require light pre-processing of the JSON before parsing as in-line YAML.
# If you want to write
# a block-commented Haiku
# you'll need three pound signs
这篇关于您如何在YAML中阻止评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!