YAML is case sensitive

YAML is not a programming language like Python, Java, or JavaScript. The format is used to define configuration files and serialise data.

 

Plungins for setting YAML in VS Code Editor for Python Support

  • Perquisites: First install Visual Studio and Python
  • Plugins
    • pip3 install PyYAML
    • pip3 install ruamel.yaml
  • These package will parse and display YAML files in tabular fashion, to visualise our YAML file.

 

 

Syntax for YAML

  • Key: Value
    • name: Deepak Talwar
    • name: “Deepak Talwar”
    • name: ‘Deepak Talwar’
    • IMP: If we don't give the space then immediately this entire content is going to be considered as a single key.
    • YAML parser It is going to construct this as a string data because the content of this value is alphabets. based upon the value, YAML parser will try to interpret the data type of the key.
  • Key scope
    • is_student: false
    • Apart from normal alpha numeric values, you can also use special characters inside the key.
  • List Type
    • All Value of a list comes from next line
    • Every list element has to start with a A tab, then a hyphen followed by a space n then values
    • A Tab at starting is optional
      • OR
  • Dictionary 
    • A Person is a dictionary with keys name, age, gender, is_student, hobbies and address
    • name is a string
    • age is an integer
    • is_student is a boolean
    • hobbies are list of string
    • address is nested dictionary 
      • Complete example

 


Related Question