一、入门
1.概念:
 yml是YAML("YAML Ain't a Markup Language)语言文件,以数据为中心,而不是一标记语言为重点,比json,xml更适合做配置文件。

为什么它比json,xml更适合做配置文件?
因为yml比xml,json代码更简洁,以数据为中心,而xml文件有自己的标签,json属性必须带有双引号。

2.语法

  • K:(space)V ==>与json写法一样
  • 使用缩进表示层级关系
  • 缩进是不允许Tab键,只允许使用space
  • 缩进的空格数且不重要,只要相同层级的元素左侧对齐
  • 大小写敏感

二、使用

多行缩进

house:
  family:
    name: Doe
    parents:
      - John
      - Jane
    children:
      - Paul
      - Mark
      - Simone
  address:
    number: 34
    street: Main Street
    city: Nowheretown
    zipcode: 12345
单行缩进

house:
  family: { name: Doe, parents: [John, Jane], children: [Paul, Mark, Simone] }
  address: { number: 34, street: Main Street, city: Nowheretown, zipcode: 12345 }