All about YAML

All about YAML

YAML (YAML Ain't Markup Language) is a industry-leading format and human-readable data serialization language. It's designed to be easy for humans to read and write while also being easily interpreted by machines.

Importance of YAML

If you take any product like GitHub Actions, AWS, GCP, Azure, Docker, Kubernetes, Jenkins, Cloud platforms,

Chef, or Puppet. So all these industry-leading products, are leveraging/supporting YAML as a data format to define configurations inside these products.

So YAML evolved as an replacement for XML configurations and JSON configurations, which is very tough for any human being to write them because they are more verbose in nature and they follow a lot of syntaxes. Where as YAML is more human friendly and it follows very less syntax, and it's very easy to write and understand YAML for any person, even the person is coming from a non-technical background.

Introduction to YAML

✿ YAML is not a markup languages like json and xml that is why it is called. "YAML ain't markup language " --> YAML is not a markup language

✿ YAML is superset of json which means ☛ YAML includes everything that JSON offers (making it compatible and able to represent all JSON data) while introducing extra features like a more human-readable format, support for comments, more data types, and a more expressive syntax. ☚

XML Vs JSON Vs YAML

✿ XML: XML is a markup language designed to store and transport data, with a focus on being human-readable and machine-understandable. It uses tags to define elements and their structure in a hierarchical format. XML is known for its flexibility but criticized for verbosity and complexity.

✿ JSON: JSON is a lightweight, text-based data interchange format inspired by JavaScript object syntax. It uses key-value pairs and arrays to represent data objects, making it easily readable by machines. Became popular due to its simplicity, ease of use, and compatibility with various programming languages. Widely used in web development, APIs, and data exchange between systems.

✿ YAML : YAML is a human-readable data serialization language. It aims to be even more human-readable and straightforward than JSON by utilizing indentation and a more intuitive syntax. YAML supports complex data structures and includes features like comments, making it easier for humans to write and read.

When 2 machines need to exchange data then JSON is more useful. When human wants to understand, then YAML is preferred.

✿ If we want to validate YAML in our local, then use yamllint.

Rules

Sample YAML file

Scalars