4

What is this yaml structure from the file invoice.yaml?

items:
    - part_no:   A4786
      descrip:   Water Bucket (Filled)
      price:     1.47
      quantity:  4

    - part_no:   E1628
      descrip:   High Heeled "Ruby" Slippers
      size:      8
      price:     133.7
      quantity:  1

If items were a list each line would would start with a dash. The lines without a dash would be key:value pairs in the items dictionary. But what is the line with the dash, a list of one key:value pair? I don't see the point of that.

I've seen this structure in lots of YAML files for configuring k8s or cloud, but none of the docs or examples I can find explain what this structure is.

Thanks.

Dean Schulze
  • 9,633
  • 24
  • 100
  • 165
  • Does this answer your question? [YAML equivalent of array of objects in JSON](https://stackoverflow.com/questions/33989612/yaml-equivalent-of-array-of-objects-in-json) – Kalle Richter Sep 11 '22 at 11:48

1 Answers1

1

Found a very good answer here. The items is a list of mappings. In JSON items would be an array of objects.

Dean Schulze
  • 9,633
  • 24
  • 100
  • 165
  • Oooh that clears some things up. I was always confused in GitHub actions why some lines in a job started with a dash and others didn't. A JSON example would probably help. – Felix Jassler May 24 '23 at 16:22