YAML
YAML is a data serialization language designed to be human-friendly and work well with modern programming languages for common everyday tasks. Additionally any valid JSON document is also a valid YAML document.
Syntax
Indentation:
Indentation is used to represent the structure of the data. Spaces or tabs can be used, but consistency is crucial.
Key-Value Pairs:
Data is represented as key-value pairs using a colon (:) to separate the key and value.
Comments:
Comments can be made with # symbol.
key: value # My Comment
# Another commentLists / Sequences:
Lists are represented using a hyphen (-) followed by a space.
key: value
list:
- item1
- item2Mappings:
Mappings represent key-value pairs.
key: value
nested:
key: valueData Types
YAML support many different data types such as strings, numbers and booleans.
mystr: "Hello World"
mynum: 3
myfloat: 3.1415
mybool: true
multiline: |
hello world
this is multiline
key: valueCommon Use Cases
1. Configuration Files:
YAML is widely used for configuration files in applications and systems.
3. CI/CD Pipelines:
Many CI/CD tools, such as GitLab CI and GitHub Actions, use YAML for defining pipelines.