YAML中的流映射表示鍵-值對的無序集合。它們也稱爲映射節點。請注意,密鑰應保持唯一。如果流映射結構中存在鍵的重複,則會生成錯誤。密鑰順序在序列化樹中生成。
Example
流映射結構的示例如下所示−
%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映射結構中保持唯一。