【问题标题】:What is a yaml structure when one line has a dash and other lines at the same level don't?当一条线有破折号而同一级别的其他线没有破折号时,什么是 yaml 结构?
【发布时间】:2023-03-18 13:04:01
【问题描述】:

invoice.yaml 文件中的这个 yaml 结构是什么?

items:
    - part_no:   A4786
      descrip:   Water Bucket (Filled)
      price:     1.47
      quantity:  4

    - part_no:   E1628
      descrip:   High Heeled "Ruby" Slippers
      size:      8
      price:     133.7
      quantity:  1

如果项目是一个列表,每行将以破折号开头。没有破折号的行将是项目字典中的键:值对。但是破折号的行是什么,一个键:值对的列表?我不明白这一点。

我在许多用于配置 k8s 或云的 YAML 文件中都看到了这种结构,但我找不到的文档或示例都没有解释这种结构是什么。

谢谢。

【问题讨论】:

    标签: yaml


    【解决方案1】:

    找到了一个很好的答案here。项目是映射列表。在 JSON 中,项目将是一个对象数组。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-05
      • 2016-06-06
      • 2015-07-29
      • 2022-11-18
      • 1970-01-01
      • 2012-08-24
      相关资源
      最近更新 更多