YAML 基本语法

目录

YAML

  • --- 开始,以 ... 结尾。
  • 同一级别的成员(e.g. List 元素)使用 - 来辨识。
  • 注释以 # 开头。

Boolean

boolean 值的写法没有严格限制。

create_key: yes
needs_agent: no
knows_oop: True
likes_emacs: TRUE
uses_cvs: false

String 对象

使用 | 换行、> 忽略换行。

include_newlines: |
            exactly as you see
            will appear these three
            lines of poetry

ignore_newlines: >
            this is really a
            single line of text
            despite appearances

List & Hash 对象

  • List
fruits:
    - Apple
    - Orange
    - Strawberry
    - Mango
  • Hash
martin:
    name: Martin D'vloper
    job: Developer
    skill: Elite
  • List、Map 混用
- martin:
	name: Martin D'vloper
    job: Developer
    skills:
      - python
      - perl
      - pascal
- tabitha:
    name: Tabitha Bitumen
    job: Developer
    skills:
      - lisp
      - fortran
      - erlang
  • List、Hash 简写
martin: {
    
    name: Martin D'vloper, job: Developer, skill: Elite}
fruits: ['Apple', 'Orange', 'Strawberry', 'Mango']

猜你喜欢

转载自blog.csdn.net/Jmilk/article/details/108553119
今日推荐