YAML
YAML is a human friendly data serialization standard for all programming languages.
- 
    大小写敏感 
- 
    使用缩进表示层级关系 
- 
    缩进时不允许使用Tab键,只允许使用空格。 
- 
    缩进的空格数目不重要,只要相同层级的元素左侧对齐即可 
- 
    #表示注释,从这个字符一直到行尾,都会被解析器忽略
Object
- Use :to split, right side must has blank.
name: ryo
in js:
{ name: 'ryo' }
- Or like this
person: {name: ryo, age: 21}
in js:
{ person: { name: 'ryo', age: 21 } }
Array
Start with -, like this
- apple
- box
- cat
- dog
in js:
[ 'apple', 'box', 'cat', 'dog' ]
- The sub-member of array can sign like this
-
  - apple
  - box
  - cat
in js:
[ [ 'apple', 'box', 'cat' ] ]
- Inline nation
array: [apple, box]
in js:
{ array: [ 'apple', 'box' ] }
Multi use array and object:
names:
 - Ryo
 - Kyo
 - May
animations:
 - Key: Kanon
 - Key: ReWrite
 - Key: CLANNAD
in js:
{ names: [ 'Ryo', 'Kyo', 'May' ],
  animations: [ { Key: 'Kanon' }, { Key: 'ReWrite' }, { Key: 'CLANNAD' } ] }
Primitive Type
- Number
age: 12
in js:
{ age: 12 }
- Bool
Use true or false
isTrue: false
in js:
{ isTrue: false }
- Null
null use ~ to express
memory: ~
in js:
{ memory: null }
- Time
time use ISO8601 type:
time: 2016-10-26t21:59:43.10-05:00
in js:
{ time: Thu Oct 27 2016 10:59:43 GMT+0800 (CST) }
- Date
date use multi iso8601 year, month, day
date: 1970-01-01
in js:
{ date: Thu Jan 01 1970 08:00:00 GMT+0800 (CST) }
- YMAL can use !!to force the type
name: !!str ryo
age: !!int '56'
in js:
{ name: 'ryo', age: 56 }
String
String default is no need use ``
str: this is a string demo
in js:
{ str: 'this is a string demo' }
If there has space or special word in your string, use ’‘ or ”“
name: "hou: ryo"
in js:
{ name: 'hou: ryo' }
The diff between ’‘ and ”“ is:
- special word in ’‘ will be transfer, but in ”“ will not
double quote: "long \n long story"
single quote: 'long \n long story'
in js:
{ 'double quote': 'long \n long story',
  'single quote': 'long \\n long story' }
单引号之中如果还有单引号,必须连续使用两个单引号转义。
name: 'mary''s song'
in js:
{ name: 'mary\'s song' }
字符串可以写成多行,从第二行开始,必须有一个单空格缩进。换行符会被转为空格
long string
 a
 ha
 ha
in js:
'long string a ha ha'
多行字符串可以使用|保留换行符,也可以使用>折叠换行
this: |
 angle
 beats
that: >
 little
 busters
in js:
{ this: 'angle\nbeats\n', that: 'little busters\n' }
- +表示保留文字块末尾的换行,- -表示删除字符串末尾的换行
one: |
 Spring
two: |+
 Summer
three: |-
 Autumn
in js:
{ one: 'Spring\n', two: 'Summer\n\n\n', three: 'Autumn' }
String can insert HTML
string with html: |
 <p class="red">
     red
 </p>
in js:
{ 'string with html': '\n<p class="red">\n    red\n</p>\n' }
Quote
You can use like this:
Author: &author
  name: ryo
  age: 11
Blog:
  info: learn note
  <<: *author
Artile:
  info: sth just like
  <<: *author
in js:
{ Author: { name: 'ryo', age: 11 },
  Blog: { info: 'learn note', name: 'ryo', age: 11 },
  Artile: { info: 'sth just like', name: 'ryo', age: 11 } }
