🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

json-schema

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema

JSON Schema validation and specifications

0.2.0
Source
npm
Version published
Weekly downloads
26M
-17.34%
Maintainers
1
Weekly downloads
 
Created

What is json-schema?

The json-schema npm package is used to validate JSON data against a JSON schema. It ensures that the JSON data is structured in the way that is expected by the schema. This package can be used to validate configuration files, user input, or any other data represented in JSON format.

What are json-schema's main functionalities?

Validation

This feature allows you to validate JSON data against a schema. The code sample demonstrates how to define a schema and validate data against it, printing out whether the data is valid or not.

{"const validate = require('json-schema').validate; const schema = {type: 'object', properties: {name: {type: 'string'}, age: {type: 'number', minimum: 0}}, required: ['name', 'age']}; const data = {name: 'John Doe', age: 28}; const result = validate(data, schema); if (result.valid) {console.log('Valid!');} else {console.log('Invalid:', result.errors);} }

Schema Compilation

This feature compiles a JSON schema for faster validation of multiple data sets. The code sample shows how to compile a schema which can then be used to validate data more efficiently.

{"const jsonSchema = require('json-schema'); const schema = {type: 'object', properties: {name: {type: 'string'}, age: {type: 'number', minimum: 0}}, required: ['name', 'age']}; const compiledSchema = jsonSchema.compile(schema); }

Other packages similar to json-schema

Keywords

json

FAQs

Package last updated on 06 Jul 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts