Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding YAML

Tags:

yaml

I am trying to understand very basic concept of YAML. I didn't find any relevant documentation which can clear my doubts. For example:

product:
    - sku         : BL394D
      quantity    : 4
      description : Basketball
      price       : 450.00
    - sku         : BL4438H
      quantity    : 1
      description : Super Hoop
      price       : 2392.00
tax  : 251.42
total: 4443.52

product is, I guess, a sequence with:

- sku         : BL394D

As data. I have read that in YAML you can define a sequence as:

name:
 -a
 -b
 -c

My question is that in product sequence what are these values? They do not have a hyphen in front of them as items of sequence has.

      quantity    : 4
      description : Basketball
      price       : 450.00

Do they also belong to sequence or are nested key: value pairs for sku? I am totally confused. Help me understand the very basic syntax with example of list, maps and nesting lists inside maps and vice-versa.

like image 982
thinkingmonster Avatar asked Oct 19 '22 04:10

thinkingmonster


1 Answers

product is a sequence of two maps, each of them containing a sku, a quantity, a description and a price entry.

You can find some examples and description here.

like image 152
Robert Hegner Avatar answered Oct 22 '22 23:10

Robert Hegner