Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 5.55 KB

about-yaml.md

File metadata and controls

58 lines (38 loc) · 5.55 KB

About YAML

YAML is a human-readable data serialization language that is commonly used for configuration files and in applications where data is being stored or transmitted

  • It is designed to be easy to read and understand, and it uses a minimal syntax that intentionally differs from Standard Generalized Markup Language (SGML)
  • YAML is a strict superset of JSON, which means that it can do everything that JSON can and more
  • One major difference between YAML and JSON is that newlines and indentation actually mean something in YAML, as opposed to JSON, which uses brackets and braces
  • YAML is a popular programming language because it is designed to be easy to read and understand. It can also be used in conjunction with other programming languages
  • YAML files use a .yml or .yaml extension, and follow specific syntax rules
  • YAML has features that come from Perl, C, XML, HTML, and other programming languages
  • YAML also contains scalars, which are arbitrary data (encoded in Unicode) that can be used as values such as strings, integers, dates, numbers
  • YAML is used in many applications, including configuration files, messages between applications, and saving application state
  • It is used mainly in the DevOps domain, where it is widely used with well-known tools such as Kubernetes, Ansible, Terraform, and many others
  • YAML is also used by the Ansible automation tool to create automation processes, in the form of Ansible Playbooks
  • YAML is a powerful language that can be used for a variety of purposes. If you're interested in learning more about YAML and its applications, there are many resources available online, including tutorials, documentation, and blog post
  • YAML has features that come from Perl, C, XML, HTML, and other programming languages
  • YAML also contains scalars, which are arbitrary data (encoded in Unicode) that can be used as values such as strings, integers, dates, numbers
  • YAML files are structured using indentation and whitespace, and are often used for configuration files and in applications where data is being stored or transmitted
  • YAML files are made up of key/value pairs, which are commonly called a “hash” or a “dictionary”
  • Sequences in YAML are represented by using the hyphen (-) and space, and are ordered and can be embedded inside a map using indentation4
  • YAML also supports comments, which begin with the (#) character and must be separated from other tokens by whitespaces

Here are the basic syntax rules and elements for YAML

So, YAML is a human-readable data serialization language that is often used for configuration files, and it supports various data types, such as strings, numbers, and boolean values. The basic syntax of YAML involves key-value pairs in the format key: value and using spaces to indicate nesting.

  • Key-value pairs: YAML uses key-value pairs to store data in a hierarchical structure. The key is the first line of a newline, and the value follows it, also on a newline.

  • Spaces and indentation: Spaces are used to indicate nesting in YAML. Indentation is not used for indentation in YAML files. Comments: Comments in YAML begin with the # character and must be separated from other tokens by whitespaces.

  • Lists and arrays: List members are denoted by a leading hyphen - and enclosed in square brackets. Associative arrays are represented using : in the format of key-value pairs and enclosed in curly braces {}.

  • Scalar types: YAML supports various scalar types, such as strings, numbers, and boolean values. Scalar values can span multiple lines, and YAML processes the first value as ending with a carriage return and linefeed.

  • Folding: Folded text converts newlines to spaces and removes leading whitespace.

  • Tags: Tags can be used to explicitly specify a type for a value. For example, !!str indicates a string value, !!int indicates an integer value, and !!bool indicates a boolean value.

  • Anchors and aliases: YAML allows the use of anchors and aliases to reuse values in the document. Anchors can be used to define a value once and then reference it elsewhere in the document using its anchor name.

YAML is a human-readable data serialization language that is often used for writing configuration files, and it is recommended over JSON in many cases due to its better readability and user-friendliness. Some good use cases for YAML include:

  • Configuration files: YAML is commonly used to create configuration files for applications and services, as it is easier to read and understand than JSON.

  • Cross-language data sharing: YAML is language-independent, meaning it can be used across various programming languages, making it suitable for data sharing between different languages.

  • Log files: YAML can be used to store log files, as it can easily represent complex data structures and is human-readable.

  • Debugging complex data structures: YAML is useful for debugging and managing complex data structures, as it provides a clear and concise way to represent and understand the data.

  • Interprocess messaging: YAML can be used for interprocess messaging, as it can represent complex data structures and is easy to read.

  • Object persistence: YAML can be used for object persistence, as it can store and manage data in a flexible and human-readable format.

  • Automation processes: YAML is used by Ansible® to create automation processes, in the form of Ansible Playbooks, which are easy to read and understand.

YAML is often preferred over other data serialization languages like JSON or XML due to its focus on data rather than documents, and its flexibility and accessibility.