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

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…

Contents