What is YAML?

What is YAML?

YAML Ain't a Markup Language. This is the full form of YAML.

Why YAML ?

YAML is a serialization language.

Means that it is used to transfer the data from one end to other like from the backend to the frontend and it is also used to store data in key value type format.

It is like JSON and XML.

YAML is popularly used for config files because it is very simple and easy to understand.

YAML Syntax

# This is a comment

# this indicates the start of a document
--- 

courses:
  # strring
  courses_name: "Django Backend Developer"
  # number
  version: 1.5
  price: &price_variable 199    # declaring a variable
  # bool
  is_public: true
  # date => yyyy-mm-dd hh:mm:ss(optional)
  release_date: 2021-04-05 12:23:22
  # null
  pre_enroll: null
  # this is an array
  tags: 
    - python
    - web Developer
    - mysql
  # this is an array
  course_ta: ["harshit", "aayush", "sanjeev", "babita"]
  # These are objects 
  ta_details: 
    - name: "harshit"
      email: "hello@gmail.com"
      role: "content admin"
    - name: "aayush"
      email: "hello2@gmail.com"
      role: "discussion admin"
    - {name: "sanjeev", email: "hello3@gmail.com", role:"developer"}
  # use > to write in multiple lines but it will change new lines into spaces 
  short_desc: > 
    here is a short
    description in django couse
  # this | symbol will keep the  formating and extra spaces 
  long_desc: | 
    now we can store 
      all indentstion and 
    related things. 
  # this is how to use a variable 
  process_payment: *price_variable

  adv: &adv 
    myKey: myval

  another_adv: 
    one: tow
    # this is how you bring all the content what is under adv in place of <<: *adv
    <<: *adv


# this indicates the end of a document
...

Did you find this article valuable?

Support Harshit Saini by becoming a sponsor. Any amount is appreciated!