YAML – Basic Components

Basic Components of YAML file
In this topic you will learn about basic types and syntaxes that are used in YAML file.
YAML file can be formatted into three types
  • Conventional Block format
  • Inline format
  • Folded Text format
Conventional Block format – The format that is followed in this is hyphen(-) and space(” “).
Example:
--- # Learning resources in tcs
- Fresco play
- Lynda
- Skillsoft
- Safari
Inline format – It is delimited with comma(,) and space(” “).
Example:
--- # Learning resources in tcs
[Fresco play, Skillsoft, Lynda, Safari]
Folded Text – It converts newlines to spaces and removes leading white spaces.
Example:
- {name: tcs, founded: 1968}
            or
- name: tcs
  founded: 1968
Indentation
Spacing/Indentation – As you know that YAML doesn’t allow any tab spaces, but it follows spaces between element parts.
Example – Key: Value

 

CommentsYAML supports only single-line comments. Comments are not supported in scalars but in collections it is vice-versa. The shortcut key for commenting block is Ctrl+Q.
syntax: # this is a comment
comments in collection
Benefits of YAML
  • YAML data can be portable with many programming languages like Perl, Python, PHP, Ruby and JavaScript.
  • It is easily readable and editable.
  • It can be easily implemented.
  • It consists of data consistent model.
  • It supports one-direction processing.
Comparisons
Comparison between YAML, JSON & XML
  • YAML has some advantages over JSON like self reference, support for complex datatypes, embedded block literals, comments, and more.
  • JSON is only readable whereas YAML can be readable as well as editable.
  • JSON is a subset of YAML so that YAML parsers can be able to parse JSON.
  • YAML doesn’t use any extra delimiters. So it is light-weight than XML and JSON.
Did You Know ?
YAML file is case-sensitive and you can save the YAML file in .yaml or .ymlextension. YAML doesn’t allow any tabs while creating a YAML file.

Cool Stuff Below !

Like
Like Love Haha Wow Sad Angry
1

Related Articles