YAML(摘录)

YAML:维基百科

一个用来表达数据序列的格式。强调以数据为中心的标记语言。

使用空白符缩进和大量依赖外观的特殊,适合编辑数据结构,配置文件。


基本格式:

缩进/区块 和内置两者格式,来表示array(清单)和hash。

array:

 --- # 最喜愛的電影 (block格式)
 - Casablanca
 - North by Northwest - Notoriou
 --- # 購物清單 (inline格式)
 [milk, pumpkin pie, eggs, juice]

hash:

 --- # 區塊形式
   name: John Smith
   age: 33  --- # 內置形式 {name: John Smith, age: 33}

注意:---无意义。 array和hash可以互相嵌套。

如:⬇️是一个[{name: John, age:33}, {name: Mary, age: 27}]

- {name: John Smith, age: 33} - name: Mary Smith age: 27

如:{ men: [...], women: [...]} 

men: [John Smith, Bill Jones] women: - Mary Smith - Susan Williams

block的字符: string无需包在引号内。可以保存新行(使用|字符),可以折叠新行(使用>字符

JSON是YAML1.2的子集。

 

猜你喜欢

转载自www.cnblogs.com/chentianwei/p/9417772.html