All Projects → ahungrynoob → jsonschema

ahungrynoob / jsonschema

Licence: MIT license
A node package based on jsonschema-rs for performing JSON schema validation

Programming Languages

typescript
32286 projects
rust
11053 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to jsonschema

jackson-json-reference
JSON Reference for Java with Jackson.
Stars: ✭ 21 (-56.25%)
Mutual labels:  json-schema
json-schema
Clojure library JSON Schema validation and generation - Draft-07 compatible
Stars: ✭ 52 (+8.33%)
Mutual labels:  json-schema
mock-json-schema
Simple utility to mock example objects based on JSON schema definitions
Stars: ✭ 23 (-52.08%)
Mutual labels:  json-schema
jest-json-schema
✨ JSON schema matcher for Jest
Stars: ✭ 152 (+216.67%)
Mutual labels:  json-schema
api-data
Static JSON data from the API, plus a JSON Schema
Stars: ✭ 88 (+83.33%)
Mutual labels:  json-schema
openapi4j
OpenAPI 3 parser, JSON schema and request validator.
Stars: ✭ 92 (+91.67%)
Mutual labels:  json-schema
as-typed
Ambient mapping from JSON schema to typescript
Stars: ✭ 97 (+102.08%)
Mutual labels:  json-schema
jsonSchema-to-uml
A tool to generate UML class diagrams from JSON schema documents
Stars: ✭ 33 (-31.25%)
Mutual labels:  json-schema
express-objection-starter
an opinionated, production-ready, isomorphic express/knex/objection starter with centralized configuration
Stars: ✭ 19 (-60.42%)
Mutual labels:  json-schema
Rockets
REST and websockets C++ library
Stars: ✭ 39 (-18.75%)
Mutual labels:  json-schema
MOSP
A collaborative platform for creating, editing and sharing JSON objects.
Stars: ✭ 72 (+50%)
Mutual labels:  json-schema
ans-schema
JSON schema definition and supporting example/validation code for The Washington Post's ANS specification
Stars: ✭ 92 (+91.67%)
Mutual labels:  json-schema
json-validator
A json validator in PHP
Stars: ✭ 52 (+8.33%)
Mutual labels:  json-schema
libgltf
glTF 2.0 parser/loader for C++11, supports many extensions likes `KHR_draco_mesh_compression`, `KHR_lights_punctual`, `KHR_materials_clearcoat`, and more.
Stars: ✭ 55 (+14.58%)
Mutual labels:  json-schema
express-json-validator-middleware
Express middleware for validating requests against JSON schema
Stars: ✭ 148 (+208.33%)
Mutual labels:  json-schema
finspec-spec
Multi-protocol, machine-readable specifications for financial services
Stars: ✭ 18 (-62.5%)
Mutual labels:  json-schema
jsonresume-theme-caffeine
Caffeine theme for the JSON Resume project
Stars: ✭ 78 (+62.5%)
Mutual labels:  json-schema
babl
JSON templating on steroids
Stars: ✭ 29 (-39.58%)
Mutual labels:  json-schema
typescript-to-json-schema
Generate JSON schema from your Typescript sources
Stars: ✭ 54 (+12.5%)
Mutual labels:  json-schema
helm-schema-gen
So that you don't have to write values.schema.json by hand from scratch for your Helm 3 charts. [CURRENTLY NOT MAINTAINED]
Stars: ✭ 104 (+116.67%)
Mutual labels:  json-schema

@node-rs/jsonschema

https://github.com/ahungrynoob/jsonschema/actions

A node package based on jsonschema-rs for performing JSON schema validation.

Bench

ajv is much faster than this lib.

Hardware

Model Name:	MacBook Pro
Model Identifier:	MacBookPro16,1
Processor Name:	6-Core Intel Core i7
Processor Speed:	2.6 GHz
Number of Processors:	1
Total Number of Cores:	6
L2 Cache (per Core):	256 KB
L3 Cache:	12 MB
Hyper-Threading Technology:	Enabled
Memory:	32 GB

Result

Running "Validate Sync" suite...
Progress: 100%

  @node-rs/jsonschema::validate:
    2 642 863 ops/s, ±1.42%    | slowest, 92.86% slower

  ajv::validate:
    36 997 776 ops/s, ±0.46%   | fastest

Finished 2 cases!
  Fastest: ajv::validate
  Slowest: @node-rs/jsonschema::validate

Install

yarn add @node-rs/jsonschema

Support matrix

Operating Systems node12 node14 node16
Windows x64
Windows x32
Windows arm64
macOS x64
macOS arm64
Linux x64 gnu
Linux x64 musl
Linux arm gnu
Linux arm64 gnu
Linux arm64 musl
Android arm64
FreeBSD x64

Usage

const { compile } = require("@node-rs/jsonschema");

const schema = {
  type: 'object',
  properties: {
    foo: { type: 'integer' },
    bar: { type: 'string' },
  },
  required: ['foo'],
  additionalProperties: false,
};

const input = JSON.stringify({
  foo: 1,
  bar: 'abc',
})

const exceptionInput = JSON.stringify({
  foo: 'abc',
  bar: 1,
})

const validator = compile(schema);

// check whether the input meet schema
const result = validator(input);
console.log(result); // true

const result = validator(exceptionInput);
console.log(result); // false

API

export declare class JSONSchema {
  isValid(input: any): boolean
}

export const compile: (schema: any) => (input: string) => boolean
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].