YAML stands for Yet Another Markup Language. It is a data serialization language just like JSON.
Why YAML, when we already have JSON or XML?
- YAML files are easy to read and write for humans, similar to English.
Foundation of YAML

- YAML files should end as .yaml or .yml
- Begins with --- and ends with …
- # defines comment
YAML is Case and Indentation Sensitive
- Members of a list should be at the same indentation level starting with a dash(-) and space.
- Each item in the list is a key: value pair (colon must be followed by a space), called a dictionary.
- At each level, exactly two spaces are used for indentation. Using tabs is not recommended here.
Boolean Values
Variables can be defined in YAML files as shown:
stream: Java
allocated: true
allocated: yes
allocated: no
allocated: True
allocated: TRUE
allocated: false Variables can be assigned boolean values in different ways as shown:
Data Structures
Complicated data structures are possible in YAML.
You can define lists having dictionaries, dictionaries having lists or a mix of both.
In the following example,
- name and job are dictionaries. Skill is a dictionary with a list.
- David and Amy are listed as having dictionaries
# Employee records
- David:
name: David Moore
job: Developer
skills:
- python
- sql
- java
- Amy:
name: Amy Brown
job: Developer
skills:
- angular
- redux
- react
No comments:
Post a Comment