syntax - 多行字符串作为序列的一部分

标签 syntax yaml

我不知道如何在Yaml序列中使用多行字符串:

foo:
  - bar
  - bar2
  - > super duper long
 string that I would like
 to have on multiple lines
  - Another item

可能吗?

最佳答案

如果要使用折叠标量:

foo:
  - bar
  - bar2
  - >
     super duper long
     string that I would like
     to have on multiple lines
  - Another item

请注意,折叠标量 header 的行(带有>的行)上可能没有内容。

另外,您可以只使用普通标量:
foo:
  - bar
  - bar2
  - super duper long
    string that I would like
    to have on multiple lines
  - Another item

关于syntax - 多行字符串作为序列的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46696057/

相关文章:

python - 自动 Ansible 文档如何工作?

maven - 类型为String []的Maven参数的语法是什么

c - 如何声明一组具有非线性依赖的结构?

c - printf 中的三元运算符

Javascript初学者语法问题

python - 我的 'for' 循环中的 python 语法无效

postgresql - 无法使用 docker-compose 为 Postgres 设置密码

c++ - 为什么 const YAML::Node 对象的行为不像具有 yaml-cpp 的类值对象?

python - 将正则表达式添加到 yaml python

gulp - 使用 Gulp 修改现有 YAML 值