Post

YAML

Introduction

  • YAML is a data serialization language that is often used for writing configuration files.
  • It is human readable and easier to understand and can be used in conjuction with other programming languages.
  • Uses Python style indentation (whitespaces are allowed - tabs are not allowed) to indicate nesting.
  • No format symbols like braces, squares brackets or quotation tags.
  • Extension can be .yml or .yaml

Structure of YAML file:

  • Structure of a YAML file is a map or a list.
  • Maps allow us to associate key-value pair. Ex.:
    1
    
    name: John Doe
    
  • Keys must be unique and the order does not matter.

YAML Data Types

  1. Scalars - Strings, integers, dates, numbers or boolean
  2. List.
  3. Dictionary
  4. Array of Objects

Sample YAML File:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# This is a comment
name: John Doe
age: 30
# List
email: 
 - johndoe@example.com
 - johndoe@domain.com
# Dictionary
address:
 - street: "123 Main St"
 - city: Anytown
 - state: Anystate
 - country: Anyland
# Array of Objects
skills:
 - name: Terraform
   proficieny: Advanced
 - name: Security
   proficieny: Beginner
 - name: AIML
   proficieny: Beginner
# Multi-Line String
short_summary: >
    Cloud Engineer with vast experience in Cloud deployment and maintainance.
    Azure Certified with knowledge in Security.
    Terraform Certified.
complete_summary: |
    Cloud Engineer with vast experience in Cloud deployment and maintainance.
    Azure Certified with knowledge in Security.
    Terraform Certified.
This post is licensed under CC BY 4.0 by the author.