bingoohuang / weekly

weekly
MIT License
9 stars 0 forks source link

[202007]YAML简单用用就好 #67

Closed bingoohuang closed 4 years ago

bingoohuang commented 4 years ago

我为什么开始用YAML呢?

  1. 因为想写注释,所以想到了YAML
  2. YAML基础语法很简洁
  3. K8S大量使用也使得它非常流行(或者反过来说也行,因为YAML很流行,K8S用了它)

下面一个简单的例子来自于Ansible中文权威指南

---
# 一位职工记录
name: Example Developer
job: Developer
skill: Elite
employed: True
foods:
    - Apple
    - Orange
    - Strawberry
    - Mango
languages:
    ruby: Elite
    python: Elite
    dotnet: Lame

image

因为对JSON很熟悉,所以把YAML转换为JSON,来验证是否符合自己的期望,例如以下实验YAML多行文本的写法:

image