YAML introduction
YAML stands for Ain’t Markup Language
, and new data format for serialization language like toml or ini file format.
These files contain text data arranged in a hierarchical structure.
It supports Scalar types (Integer, strings, float, Boolean, Time) and collection types (array, list).
This course series of posts help you to get the basics with examples for learning.
Important points:
- It is case sensitive
- file extension is
.yaml
- Tabs are not allowed,
- Some editors allow spaces
Advantages
- Lightweight
- It is very easy and simple to represent the complex mapping
- Human friendly readable and writable
- Simple to modify with any text editor
- Suitable for configuration settings
- Support for major programming languages
Disadvantages
- It is a new format introduced recently, and a learning curve exists.
- Not much popular other than XML and JSON
- It is very complex to represent configuration in the hierarchy of data
What is the file extension
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 provide plugins to validate the yaml
file content.
What is the YAML media type?
media or MIME types exist in request headers with Content-Type
and accept
during data transfer between systems.
According to IANA, there is no official MIME type for YAML document content.
It can be represented using text/yaml
or text/x-yaml
or application/x-yaml
mime types
When yaml
data transfers between client and server, Implementation vendors add MIME type settings specified in requests and responses across the internet.
Generally, we can use the 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 these documents
text/yaml
and request contains the below value for YAML data sent over the internet.
Content-type : text/yaml
The other possible options are
- text/yaml
- text/yml
- text/x-yaml
- application/yaml
- application/yml
One of the above is considered based on the browser and the supported programming language.
For example, Chrome accepts application/yaml.
How do you open yaml files?
These files open in a simple text editor or Integrated Development editors like Visual Studio, Atom Sublime Text, Notepad++, and Intelli IDEA in Windows, UNIX, and MAC OS.
Basic editors provide only capabilities to read and write without format and validation.
IDEs provide plugins following features.
- Auto or manual Format the code
- Syntax highlights coloring
- Inline render of this content in HTML view
- Some plugins provide to export to PDF and Documents