From the course: JSON Essential Training
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Specify required properties with JSON Schema - JavaScript Tutorial
From the course: JSON Essential Training
Specify required properties with JSON Schema
- [Instructor] In addition to specifying data types for the properties of JSON data, JSON schema also allows you to specify that one or more properties are required. At this point, my schema specifies a data structure for an array that contains objects and each object contains five properties, ID, name, description, image title and image. What if I want to require that these properties must be included in order for my JSON data to be considered valid? Well, remember that each sub object within the array is itself specified by an object in JSON schema with a type property set to object and a property's property specifying the names of properties it can contain. To indicate that one or more of these properties are required, I simply add another property to the object in my JSON schema. The property must have the name required and its value is an array containing one or more strings as its elements. Each string in the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
What is JSON Schema?2m 57s
-
(Locked)
Create a basic schema with JSON Schema6m 47s
-
(Locked)
Validate JSON data against a schema3m 42s
-
(Locked)
Specify required properties with JSON Schema4m 59s
-
(Locked)
Work with schema generators7m 29s
-
(Locked)
Challenge: Work with JSON Schema52s
-
(Locked)
Solution: Work with JSON Schema4m 23s
-
(Locked)
-
-