yaml多行字符串不解析

时间:2016-12-19 22:38:24

标签: yaml

我不明白为什么第一个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的另一个“奇怪”,但为什么.....?

1 个答案:

答案 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"