what is the use of pipe symbol in yaml
我刚接触山药,有个问题。用于多行的管道符号()。yaml有下面这样的语法吗?
test: |6+
我有一个类似下面两个的yaml代码,第一个有效,第二个无效。我不知道那里发生了什么。第一个文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Name : - testing: val1 - second: val2 - third: val3 - then - final: | a aa aaa aaaa : 'test:' |
第二文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Name : - testing: val1 - second: val2 - third: val3 - then - final: |6+ a aa aaa aaaa : 'test:' |
P.S : Second file is customer's.
I am using xmlbeans and I got"com.esotericsoftware.yamlbeans.parser.Parser$ParserException: Line 17, column 12: Expected a 'block end' but found: block mapping start".
编辑在"我正在使用"附近添加了xmlbeans。
yaml中一行末尾的管道符号表示后面的任何缩进文本都应解释为多行标量值。见山药规格。
具体地说,管道指示(除缩进外)标量值应以保留换行符的方式逐字解释。相反,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | >>> import yaml >>> yaml.load(""" ... | ... This is a multi-line ... literal style scalar. ...""") 'This is a multi-line literal style scalar. ' >>> yaml.load(""" ... > ... This is a multi-line ... folded scalar; new lines are folded into ... spaces. ...""") 'This is a multi-line folded scalar; new lines are folded into spaces. ' |
您得到的错误是一个棘手的错误:这是因为缩进应该相对于当前的块级元素。因此,在这种情况下,它应该是