Socket
Socket
Sign inDemoInstall

json-schema

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

json-schema

JSON Schema validation and specifications

    0.4.0latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
19,700,319
increased by3.02%

Weekly downloads

Package description

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

Readme

Source

This is a historical repository for the early development of the JSON Schema specification and implementation. This package is considered "finished": it holds the earlier draft specification and a simple, efficient, lightweight implementation of the original core elements of JSON Schema. This repository does not house the latest specifications nor does it implement the latest versions of JSON Schema. This package seeks to maintain the stability (in behavior and size) of this original implementation for the sake of the numerous packages that rely on it. For the latest JSON Schema specifications and implementations, please visit the JSON Schema site (or the respository).

Code is licensed under the AFL or BSD 3-Clause license.

Keywords

FAQs

Last updated on 09 Nov 2021

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc