From the course: JSON Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Validate JSON data against a schema - JavaScript Tutorial
From the course: JSON Essential Training
Validate JSON data against a schema
- [Instructor] The easiest way to validate JSON data against the JSON Schema is to use a validator written for that purpose. Free open source validators exist for a number of languages, including Java, Python, Ruby and PHP, as well as browser-based utilities. For the H+ Sport website, I'll use a JavaScript validator called Ajv. Ajv is designed for backend use, but I can try the tool out without installing it by using an online instance called a REPL. The left pane shows the JavaScript code that the validator uses. I only need to work with two parts of the code. The schema variable and the test function calls. I'll open the schema.js file for this video. And I want to copy the schema content to the clipboard. Now, I only want the object itself and not the variable declaration or the equal sign. So, I'll click the beginning, click to the end, but not include the semi-colon, and copy that. And then over in the REPL, I…
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)
-
-