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 對映結構中保持唯一。

廣告
© . All rights reserved.