Good articles must be transferred: http://www.cnblogs.com/chwkai/archive/2005/10/07/beginning_yaml.html
Yaml is also a thing. In the case of XML flooding, the appearance of Yaml is really a bright, in the initial study of Yaml after a rough summary of a bit, take out and share.
[Mindmap]
[Reference Document]
YAML specification
YAML Data type description
Summary
The design purpose of YAML
Yaml Description: [Annotation, document, data structure, datatype, other]
The design purpose of YAML
1. Easy for Human to read
2, suitable for the presentation of program language data structure
3, can be used to exchange data between different programs
4. Support Generic Tools
5, support serial processing.
6, rich expression ability and scalability
7. Easy to use
After a rough look at the specification, the best feeling is "easy to read", contrast the following XML and YAML code block:
# XML code block: < site >
< name > Sina </name >
< URL > http://www.sina.com.cn </URL >
</Site >
< site >
< name > Google </name >
< URL > http://www.google.com </URL >
</Site >
# YAML code block---
Site
Name:sina
url:http://www.sina.com.cn
---
Site
Name:google
Url:http://www.google.com
OR:---
Site: {Name:sina, url:http://www.sina.com.cn}
---
Site: {name:google, url:http://www.google.com}
Yaml uses indents or explicit indicatior (such as the {} above) to indicate nesting of properties, more intuitive and simple.
YAML describes "YAML Ain ' t Markup Language" (abbreviated YAML) is a data serialization Language designed to be human-friendly and Work modern programming languages for common tasks.
First Look at the main tags in the yaml:
(1) Comment:
For example:
# Comment Example
# Profile of Mary
Mary:
&nbs p; -Name:mary
-age : 19 # Age Property
(2) document (document):
br> now don't understand what the document means, since the YAML definition is data serialization, a doucment is temporarily treated as an object serialization Yaml configuration information # documents example
& nbsp; ---
site: {name: sina, url: http://www.sina.com.cn}
---
site: { Name: google, url: http://www.google.com}
(3) Data structure:
Yaml's designers believe that there are three types of data to be expressed in the configuration file: scalars (Scalar, such as strings and integers), sequences (Sequence, arrays), and mapping (similar to the hash key/value pair).
The sequence type is primarily used to represent the type of data in an array. The following figure describes the representation of the sequence data in Yaml:
The mapping data type is used primarily to represent the data for a key:value type. YAML description is shown in the following figure:
Finally, we use Yaml to describe a book "unit Test know-c# Version" # "Unit Test Path-c# Edition" description
---# Begin with Document
Title: ' The Way of Unit Test '-c# Edition '
Publishing house: ' Electronic industry publishing house '
Original author: [' Andrew Hunt ', ' David Thomas ']
Translator:
-Chen Weiju
-Pottery Inscriptions
Top two chapters:
-Chapter I: Preamble
-Chapter II: Your first unit test plan
#end of document
YAML recommends using spaces as indents, avoiding the possibility of misunderstandings in different editors about the way tabs are represented.