抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

Offical Tutorial

Basic

key: value

Yaml will auto detect data type, but some time that’s what we don’t want. So you need Type cast :

1
age: !!str 10
  • type avaliable
    • str
    • int
    • float
    • bool
    • null
    • ISO date type:2020-1-1 11:11:22
    • array

Array

Can not use TAB in yaml. Use indentation to grading and - char to sign as a array.

1
2
3
4
5
6
arr:
- item1
- item11
- item2
- item21
- item22

Object

Can not use TAB in yaml. Use indentation to grading but no - char.

1
2
3
person:
name: ring
age: 10

Long string value

1
2
3
4
message:
a long long long
long long
long msg

To end with \n

1
2
3
4
message: >
a long long long
long long
long msg

To end with \n for each line

1
2
3
4
5
6
message: |
a long long long
long long
long msg

#a long long long\nlong long\nlong msg\n

Use Reference

Assign with pointer

1
2
3
4
5
6
father: &father_info
name: ring

monitor: *father_info

# value of monitor same as value of father

New part

Yaml not allow you have dulplicate key. You can use --- to statement in a new part

1
2
3
name: ring
---
name: ring

End of File

You can use ... to tell yaml, this is the end.

评论