YAML is a superset of JSON to represent data. So, we can specify objects and arrays in YAML.

Let’s have an object in JSON as follows

{
  "id": 1,
  "name": "Franc"
}

Above can be presented in yaml as

---
id: 1
name: Franc

Suppose you have an array of objects in JSON as

[
  {
    "id": 1,
    "name": "Franc"
  },
  {
    "id": 2,
    "name": "John"
  }
]

equivalent YAML file mapping

---
- id: 1
  name: Franc
- id: 2
  name: Joh

Suppose you have a nested array of objects with a string array for one of the properties.

[
  {
    "id": 1,
    "name": "Franc",
    "roles": [
      "admin",
      "hr"
    ]
  },
  {
    "id": 2,
    "name": "John",
    "roles": [
      "admin",
      "finance"
    ]
  }
]

In this object, roles have an array of strings.

YAML nested array of objects

---
- id: 1
  name: Franc
  roles:
  - admin
  - hr
- id: 2
  name: John
  roles:
  - admin
  - finance

One more example of a nested objects array in json

{
  "data": [
    {
      "id": 1,
      "name": "Franc",
      "roles": [
        "admin",
        "hr"
      ]
    },
    {
      "id": 2,
      "name": "John",
      "roles": [
        "admin",
        "finance"
      ]
    }
  ]
}

data property contains a nested array of objects which can be YAML as follows

---
data:
- id: 1
  name: Franc
  roles:
  - admin
  - hr
- id: 2
  name: John
  roles:
  - admin
  - finance