我正在用YamlReader(yamlbeans.YamlReader)读取yaml文件
- tag: xyz
description: |
This is multi-line comment and I want to preserve
leading white spaces and new line 当我阅读上述内容时,如下所示:
String descr = tag.get("description"); 它提供了以下产出:
This is multi-line comment and I want to preserve
leading white spaces and new line 但我想保留领先的空白。
发布于 2016-12-13 19:40:01
使用压痕指示器:
- tag: xyz
description: |1
This is a multi-line comment and I want to preserve
leading white spaces and new line1声明,以下块标量将有一个额外的缩进空间(除了当前的缩进级别),这将提供:
This is a multi-line comment and I want to preserve
leading white spaces and new line正如您所看到的,块标量中的一个缩进空间后面的两个空间被保留。您可以使用任何一位数作为缩进指示器.
如果要保留尾随换行符,请使用|1+,其中+告诉YAML保留尾换行符。
https://stackoverflow.com/questions/41127994
复制相似问题