YAML Ain't Markup Language is a data serialization language that matches user’s expectations about data. It designed to be human friendly and works perfectly with other programming languages. It is useful to manage data and includes Unicode printable characters. This chapter will give you an introduction to YAML and gives you an idea about its features.
Consider the text shown below −
Quick brown fox jumped over the lazy dog.
The YAML text for this will be represented as shown below −
yaml.load(Quick brown fox jumped over the lazy dog.) >>'Quick brown fox jumped over the lazy dog.'
Note that YAML takes the value in string format and represents the output as mentioned above.
Let us understand the formats in YAML with the help of the following examples −
Consider the following point number of “pi”, which has a value of 3.1415926. In YAML, it is represented as a floating number as shown below −
>>> yaml.load('3.1415926536') 3.1415926536
Suppose, multiple values are to be loaded in specific data structure as mentioned below −
eggs ham spam French basil salmon terrine
When you load this into YAML, the values are taken in an array data structure which is a form of list. The output is as shown below −
>>> yaml.load(''' - eggs - ham - spam - French basil salmon terrine ''') ['eggs', 'ham', 'spam', 'French basil salmon terrine']
YAML includes a markup language with important construct, to distinguish data-oriented language with the document markup. The design goals and features of YAML are given below −
Matches native data structures of agile methodology and its languages such as Perl, Python, PHP, Ruby and JavaScript
YAML data is portable between programming languages
Includes data consistent data model
Easily readable by humans
Supports one-direction processing
Ease of implementation and usage