YAML Systax

YAML (short for “YAML Ain’t Markup Language”) is a human-readable data serialization language that uses a simple syntax to structure data. The syntax is designed to be easy to read and write, making it a popular choice for configuration files and data exchange between programming languages.

The basic structure of a YAML document is a collection of key-value pairs, where each key-value pair is represented by a colon (:). Here is an example:

name: John
age: 30
city: New York

In this example, “name”, “age”, and “city” are keys, and “John”, “30”, and “New York” are their respective values. Note that the values can be of different data types, such as strings, integers, and booleans.

YAML also uses indentation to structure data. Indentation is used to indicate which values are nested within other values. Here is an example:

person:
  name: John
  age: 30
  address:
    street: Main Street
    city: New York

In this example, “person” is the key for a nested set of key-value pairs, including “name”, “age”, and “address”. “address” is itself a nested set of key-value pairs for the street and city.

YAML also supports lists and arrays using hyphens (-). Here is an example:

fruits:
  - apple
  - banana
  - orange

In this example, “fruits” is a key with a list of values: “apple”, “banana”, and “orange”.

Finally, YAML allows for comments using the “#” symbol. Comments are ignored during parsing and are used to provide notes or explanations about the data. Here is an example:

# This is a comment
person:
  name: John # This is another comment
  age: 30
Follow us on social media
Follow Author