YAML introduction

YAML stands for Ain’t Markup Language, and new data format for serialization language like toml or ini file format.

YAML files are used to store text data with arranged in hierarchical structure.

It supports Scalar types (Integer,strings,float,Boolean) as well as as collection types (array,list).

This course series posts help you to get basics of YAML with examples for learning.

Important points

  • It is case sensitive
  • file extension is .yaml
  • Tabs are not allowed,
  • Some editors allows spaces

Advantages of YAML

  • Lightweight
  • It is very easy and simple for represent complex mapping
  • Human friendly readable and writable
  • Simple to modify with any text editor
  • Suitable for configuration settings
  • Support for major programming languages

Disadvantages of YAML

  • It is new format introduced recently, learning curve exists.
  • Not much popular other than xml and json
  • It is very much complex to represent configuration in hierarchy of data

What is file extension for YAML

yaml files are created with extension .yaml or .yml. You can use any IDE or text editor to open this file.

All the popular IDE supports the yaml file extension and also provides plugins to validate the yaml file content.

What is yaml media type?

media or MIME types are used to specify in request header with Content-Type and accept during transferring data between different systems.

There is no official MIME type for YAML document content as per IANA.

It can be represented using text/yaml or text/x-yaml or application/x-yaml mime types

When yaml data is transferred between client and server, Implementation vendors add MIME type settings specified in request and response across internet. Generally we can use MIME format type - text/yaml.

Content-Type and accept headers in a request object are specified with this format.

Following is the mime type for this documents

text/yaml

and request contains the below value for yaml data sending over the internet.

Content-type : text/yaml

The other possible options can be used

  • text/yaml
  • text/yml
  • text/x-yaml
  • application/yaml
  • application/yml

These will be changed based on browser as well as supported programming language.

For example, Chrome accepts application/yaml