Array of Objects

Now let's add skills field. Which is an array of objects. Each object in the array will have two properties name and level.

Both name and level are strings.

1{
2  "name": "John Doe",
3  "age": 25,
4  "skills": [
5    {
6      "name": "JavaScript",
7      "level":"beginner"
8    },
9    {
10      "name": "React",
11      "level":"intermediate"
12    }
13  ]
14}

Schema for the Array of Objects

Start by defining skills as an array. set the items keyword to define the type of items in the array. Each item in the array will be an object with two properties name and level. See the below example.

1{
2  "skills": {
3    "type": "array",
4    "items": {
5      "type": "object",
6      "properties": {...}
7    }
8  }
9}

Now, try to modify the skills property in the schema given to you in the side editor, and make it an array of objects with name and level properties.

Loading...
Output
Please click the button or use
Shift+Enter
to view the output