@Dale-Lin
2020-11-01T07:13:11.000000Z
字数 1234
阅读 936
YAML
Playground:YAML - JavaScript parser
'' 单引号会对内部的特殊符号进行转义,"" 双引号不会--- 表示开始... 表示结束对象用冒号结构表示一对键值对:
animal: pettree: !!mapwillow: truecypress: true
{animal: 'pet',tree: { willow: true, cypress: true }}
一组开头是连词线的行:
color: !!seq- blue- yellow- pink
{color: ['blue', 'yellow', 'pink']}
纯量指单个的、不可再分的值:
true 和 false~ 表示yyyy-MM-dd hh:mm:ss +Z 来表示,其中 Z 表示时区的数字,例如 8 表示这个是东八区时间yyyy-MM-dd 表示
string: "12"number: 12.11infinity: .infnegativeInfinity: -.infoctal: 014hexadecimal: 0xcboolean: truenull: ~undefined: !!js/undefined ~time: 2020-10-29 00:00:00 +8
{string: "12",number: 12.11,infinity: Infinity,negativeInfinity: -Infinity,octal: 12,hexadecimal: 12,boolean: true,null: null,undefined: undefined,time: Thu Oct 29 2020 00:00:00 GMT+0800 (中国标准时间)}
!! 表示强制类型转换,常见的有:
pairs: !!pairs- foo: ofoo- bar: obar
{pairs: [["foo", "ofoo"],["bar", "obar"]]}
set: !!set? foo? bar
{foo: null,bar: null}
& 作为一个锚点引用变量,* 可以引用,<< 表示合并数据(如果有同名,后面的声明会覆盖前面的):
merge: &merge- &Center { x: 1, y: 2 }- &Left { x: 0, y: 3 }foo: *mergebar:<<: *Lefty: 10
{merge: [{ x: 1, y: 2 },{ x: 0, y: 3 }],foo: [{ x: 1, y: 2 },{ x: 0, y: 3 }],bar: { x: 0, y: 10 }}
