Arrays are a group of fixed-size elements. Array elements in the YAML file contain separate lines, Also called multiline array strings.

In YAML, arrays syntax is

let’s declare an array in any programming languages

["admin","finance","hr"]

Above written with yaml sequence also

---
- admin
- finance
- hr

Let’s declare key and value as an array in YAML.

roles contain an array of admin, hr and sales, finance

We have to use a sequence with key=roles, and value is a multi-line array of strings.

Here is an example of the YAML sequence that is the same as multi-line strings.

---
roles:
- admin
- finance
- hr
- sales

Also this can be represented as in multiple ways

"roles":["admin","finance","hr","sales"]

This is good as it is very easy to read and understand. or

"roles":["admin","finance","hr",
    "sales"]

Array of arrays in yaml in multiline strings

Suppose you have a list of employee objects in json which contain an array of arrays.

{
  "employees": [
    [
      "emp1",
      "emp2",
      "emp3"
    ],
    [
      "emp11",
      "emp12",
      "emp13"
    ]
  ]
}

YAML represent an array of arrays as follows

---
employees:
- - emp1
  - emp2
  - emp3
- - emp11
  - emp12
  - emp13