Maybe this will help.
YAML and JSON are two common formats employed to present structured data. There are online tools, like jsonformatter, that can convert from one format to the other.
Here’s a screenshot showing some random data I created on the left in YAML and, on the right, how the same information is presented in JSON. YAML is concise and uses indentation as a means of structuring the data whereas JSON is verbose and uses braces, brackets, double-quotes, etc. Unlike YAML, JSON doesn’t rely on indentation to convey any special meaning. However, in lieu of indentation, it has its own rules about how all of that “punctuation” should be used.
-
colors
is a list containing three items. Each item in this example is a string.
-
months
is a dictionary containing three keys and three associated values (i.e. three key-value pairs). All values in this example are integers.
-
animals
is a list containing three items. Each item is a dictionary containing two key-value pairs. All values in this example are strings
So if I wanted to create a shopping list and structure it as a YAML list, it would look something like this:
my_shopping_list:
- apples
- bananas
- oranges
- eggs
If I wanted to include more information such as quantity, I could choose to structure it as a dictionary:
my_shopping_list:
apples: 12
bananas: 8
oranges: 6
eggs: 12
If I wanted to get a bit fancier, and add more information for each thing I want to buy, I could structure it like this:
my_shopping_list:
- name: apples
qty: 12
store: ABC
- name: bananas
qty: 8
store: XYZ
- name: oranges
qty: 6
store: ABC
- name: eggs
qty: 12
store: MNO
If I wanted to offer a choice of stores for buying each item, I can replace the existing string value with a list.
my_shopping_list:
- name: apples
qty: 12
store:
- ABC
- XYZ
- name: bananas
qty: 8
store:
- ABC
- XYZ
- name: oranges
qty: 6
store:
- ABC
- QRS
- name: eggs
qty: 12
store:
- MNO
- TUV
I hope this helps, just a little bit, to demystify YAML’s use of indentation and hyphens to structure data.