我不明白为什么第一个YAML多行字符串解析,但是 嵌入为值的第二个不解析:
ignore_newlines: >
this is really a
single line of text
despite appearances
xmas: {
day: "Dec 25",
another_ignore_newlines: >
this is really a
single line of text
despite appearances
cleanup: "Dec 26"
}
这可能只是YAML的另一个“奇怪”,但为什么.....?
答案 0 :(得分:2)
In YAML it is not allowed to have block style nodes nested within flow style。并且xmas
的值是一个流样式映射,它包含another_ignore_newlines
的(折叠文字)块样式标量值。
这不起作用,因为在,
之前的行上也应该有一个尾随cleanup
。
尝试删除{
和}
以及"Dec 25"
之后的尾随逗号:
ignore_newlines: >
this is really a
single line of text
despite appearances
xmas:
day: "Dec 25"
another_ignore_newlines: >
this is really a
single line of text
despite appearances
cleanup: "Dec 26"