YAML ↔ JSON 转换工具
在YAML和JSON格式之间相互转换,支持双向转换
输入
输出
YAML语法基础
- 使用缩进表示层级关系,通常是2个空格
- 键值对使用冒号分隔:
key: value - 字符串可以不加引号,但特殊字符需要加引号
- 列表项使用短横线开头:
- item - 支持注释,以
#开头 - 多行字符串可以使用
|或>
YAML vs JSON对比
YAML:
name: John Doe
age: 30
address:
street: 123 Main St
city: Anytown
hobbies:
- reading
- cycling
- coding
JSON:
{
"name": "John Doe",
"age": 30,
"address": {
"street": "123 Main St",
"city": "Anytown"
},
"hobbies": [
"reading",
"cycling",
"coding"
]
}