Yaml-block-scalar-header

提供:Dev Guides
移動先:案内検索

YAML-ブロックスカラーヘッダー

In this chapter, we will focus on various scalar types which are used for representing the content. In YAML, comments may either precede or follow scalar content. It is important to note that comments should not be included within scalar content.

複数のキーで使用する場合を除き、すべてのフロースカラースタイルに複数の行を含めることができます。

スカラーの表現は以下のとおりです-

%YAML 1.1
---
!!map {
   ? !!str "simple key"
   : !!map {
      ? !!str "also simple"
      : !!str "value",
      ? !!str "not a simple key"
      : !!str "any value"
   }
}

ブロックスカラーヘッダーの生成された出力は以下に示されています-

{
   "simple key": {
      "not a simple key": "any value",
      "also simple": "value"
   }
}

ドキュメントマーカースカラーコンテンツ

この例のすべての文字は、内部スペース文字を含むコンテンツと見なされます。

%YAML 1.1
---
!!map {
   ? !!str "---"
   : !!str "foo",
   ? !!str "...",
   : !!str "bar"
}

%YAML 1.1
---
!!seq [
   !!str "---",
   !!str "...",
   !!map {
      ? !!str "---"
      : !!str "..."
   }
]

プレーン改行は、以下に示す例で表されます-

%YAML 1.1
---
!!str "as space \
trimmed\n\
specific\L\n\
none"

同じために対応するJSON出力は以下に記載されています-

"as space trimmed\nspecific\u2028\nnone"