YAML Ain’t Markup Language designed with flexibility, accessibility and widely used for cross-data sharing and data serialization.

Rules for Creating YAML file :
- The files should have .yaml as the extension
- YAML is case sensitive
- YAML does not support multi line comments
Basic Components of YAML File :
- Comments in YAML begins with the (#) character.
- – this sign use to start new item
- The defaults key with a prefix of “ <<: *”
- List members are denoted by a leading hyphen (-)
- List members are enclosed in square brackets and separated by commas.
- Associative arrays are represented using colon ( : ) in the format of key value pair. They are enclosed in curly braces {}.
- Multiple documents with single streams are separated with 3 hyphens ( — ).
- Repeated nodes in each file are initially denoted by an ampersand (&) and by an asterisk (*) mark later
- Mappings are the representation of key value as included in JSON structure — colon and space (:)
# A sample yaml file
company: spacelift
domain:
- devops
- devsecops
tutorial:
- yaml:
name: "YAML Ain't Markup Language"
type: awesome
born: 2001
- json:
name: JavaScript Object Notation
type: great
born: 2001
- xml:
name: Extensible Markup Language
type: good
born: 1996
author: omkarbirade
published: true
Basic YAML Syntax
- Maps/Dictionaries (YAML calls it mapping): An unordered set of key/value node pairs, with the restriction that each of the keys is unique.
- Arrays/Lists (YAML calls them sequences): A sequence node is an ordered series of zero or more nodes.
- Literals (Strings, numbers, boolean, etc.): A scalar node that can be presented as a series of zero or more Unicode characters.
Indentation
YAML file relies on whitespace and indentation to indicate nesting and hierarchy. Tab characters cannot be used for indentation; only spaces can be used. The number of spaces used for indentation doesn’t matter as long as they are consistent.
tutorial: #nesting level 1
- yaml: #nesting level 2 (2 spaces used for indentation)
name: "YAML Ain't Markup Language" #string [literal] #nesting level 3 (4 spaces used for indentation)
type: awesome #string [literal]
born: 2001 #number [literal]
Mapping
Mappings are used to associate key/value pairs that are unordered. Maps can be nested by increasing the indentation, or new maps can be created at the same level by resolving the previous one.
name: "YAML Ain't Markup Language" #mapping
type: awesome
born: 2001
Sequences Sequences in YAML are represented by using the hyphen (-) and space. They are ordered and can be embedded inside a map using indentation.
languages:
#Sequence
- YAML
- JAVA
- XML
- Python
- C
Literals — Strings
The string literals do not require to be quoted. It is only important to quote them when they contain a value that can be mistaken as a special character.
message1: YAML & JSON # breaks as a & is a special character
message2: "YAML & JSON" # Works as the string is quoted
Comments
YAML file also supports comments, unlike JSON. A comment starts with #.
--
# Comments inside a YAML file can be added followed by the '#' character
company: spacelift
Reference : https://spacelift.io/blog/yaml
Avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful again anyone
Tony R. Francois