YAML 流式映射
YAML中的流式映射表示无序的键值对集合。它们也被称为映射节点。请注意,键应该保持唯一。如果流式映射结构中有键的重复,将会生成错误。键的顺序在序列化树中生成。
示例
下面是流式映射结构的示例:
%YAML 1.1
paper:
uuid: 8a8cbf60-e067-11e3-8b68-0800200c9a66
name: On formally undecidable propositions of Principia Mathematica and related systems I.
author: Kurt Gödel.
tags:
- tag:
uuid: 98fb0d90-e067-11e3-8b68-0800200c9a66
name: Mathematics
- tag:
uuid: 3f25f680-e068-11e3-8b68-0800200c9a66
name: Logic
对于以JSON格式显示的映射序列(无序列表)的输出如下所示−
{
"paper": {
"uuid": "8a8cbf60-e067-11e3-8b68-0800200c9a66",
"name": "On formally undecidable propositions of Principia Mathematica and related systems I.",
"author": "Kurt Gödel."
},
"tags": [
{
"tag": {
"uuid": "98fb0d90-e067-11e3-8b68-0800200c9a66",
"name": "Mathematics"
}
},
{
"tag": {
"uuid": "3f25f680-e068-11e3-8b68-0800200c9a66",
"name": "Logic"
}
}
]
}
如果您观察上面显示的输出,可以看到在YAML映射结构中,关键字名称是唯一的。