📜  YAML-语法字符

📅  最后修改于: 2020-10-14 08:38:53             🧑  作者: Mango


各种类型的字符用于各种功能。本章详细讨论了YAML中使用的语法,并着重于字符操作。

指标字符

指示灯字符包括用来描述YAML文件的内容的特殊语义。下表详细显示了此内容。

Sr.No. Character & Functionality
1

_

It denotes a block sequence entry

2

?

It denotes a mapping key

3

:

It denotes a mapping value

4

,

It denotes flow collection entry

5

[

It starts a flow sequence

6

]

It ends a flow sequence

7

{

It starts a flow mapping

8

}

It ends a flow mapping

9

#

It denotes the comments

10

&

It denotes node’s anchor property

11

*

It denotes alias node

12

!

It denotes node’s tag

13

|

It denotes a literal block scalar

14

>

It denotes a folded block scalar

15

`

Single quote surrounds a quoted flow scalar

16

Double quote surrounds double quoted flow scalar

17

%

It denotes the directive used

以下示例显示了语法中使用的字符-

%YAML 1.1
---
!!map {
   ? !!str "sequence"
   : !!seq [
      !!str "one", !!str "two"
   ],
   ? !!str "mapping"
   : !!map {
      ? !!str "sky" : !!str "blue",
      ? !!str "sea" : !!str "green",
   }
}

# This represents
# only comments.
---
!!map1 {
   ? !!str "anchored"
   : !local &A1 "value",
   ? !!str "alias"
   : *A1,
}
!!str "text"