yaml学习

img

YAML是一个可读性高,用来表达数据序列化的格式,后缀.yaml.yml

语法

  • 使用缩进表示层级关系
  • 缩进的空格数不重要,只要相同层级的元素左对齐即可
  • 表示注释

基本数据类型

纯量、数组、对象

格式

null或~表示空值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#comment here
name: test
version: 5.6
port: 6379
stdin: true
image: null
#date and time
date: 2022-06-05T15:00:00+02:00

singleLineString: >- #>表示多行文字,且每行文字后的回车以空格替换,-表示不要最后一行的回车
This is a single line string
another line
and another
OtherLineString: |
This is a single line string
another line
and another
#|表示保留换行符
#数组
ports:
- 5433
- 5634
ports1: [6379, 6380]