YAML


YAML (YAML Ain’t Markup Language) is a human-readable data serialization format, often used for configuration files and data exchange. It’s designed to be more intuitive and less verbose than formats like XML or JSON.

# Comments in YAML start with the '#' symbol

# Basic Scalar Types
string_value: Hello, World!
integer_value: 42
float_value: 3.14159
boolean_value: true
null_value: null  # or ~ (tilde)

# Strings
unquoted_string: This is a string
single_quoted: 'String with ''single'' quotes'
double_quoted: "String with \"double\" quotes"

# Multi-line Strings
literal_block: |
  This is a multi-line string.
  Line breaks are preserved.
  Indentation is stripped.  

folded_style: >
  This is a multi-line string.
  Line breaks become spaces.
  Blank lines become line breaks.  

# Lists
simple_list:
  - item1
  - item2
  - item3

nested_list:
  - 
    - nested_item1
    - nested_item2
  - 
    - another_nested_item

# Dictionaries (key-value pairs)
simple_dict:
  key1: value1
  key2: value2

nested_dict:
  person:
    name: John Doe
    age: 30
    address:
      street: 123 Main St
      city: Anytown

# Complex Structures
complex_structure:
  - item1
  - key1: value1
    key2: value2
  - 
    - nested_list_item

# Anchors and Aliases
anchor_example: &anchor_name
  key1: value1
  key2: value2

alias_example: *anchor_name

merge_example:
  <<: *anchor_name
  key3: value3

# Tags
explicit_string: !!str 42
explicit_int: !!int "42"
explicit_float: !!float "3.14159"
explicit_boolean: !!bool "yes"

# Custom Tags
%TAG !custom! tag:example.com,2000:app/
---
!custom!type
  key: value

# Multiple Documents
---
document1: data
---
document2: more data

# Flow Style (compact notation)
flow_sequence: [item1, item2, item3]
flow_mapping: {key1: value1, key2: value2}

# Node Anchors
definitions:
  - &center {x: 1, y: 0}
  - &left {x: 0, y: 0}
  - &right {x: 2, y: 0}

positions:
  - *center
  - *left
  - *right

# Set Type
!!set
? item1
? item2
? item3

# Ordered Maps
!!omap
- key1: value1
- key2: value2

# Binary Data
binary_data: !!binary |
  R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOf...  

# Timestamps
iso8601: 2023-04-01T12:00:00Z
space_separated: 2023-04-01 12:00:00
no_time: 2023-04-01