Skip to content

The ultra high-performance JSON Schema validator, providing validation in the nano-second range, along with perfect compliance scores. Supports Draft 4, Draft 6, Draft 7, 2019-09 and 2020-12. For both servers and embedded devices

License

Notifications You must be signed in to change notification settings

sourcemeta/blaze

Repository files navigation

Blaze

The ultra high-performance JSON Schema validator for C++ with support for JSON Schema Draft 4, Draft 6, Draft 7, 2019-09, and 2020-12. Built on top of the powerful JSON Toolkit library.

Supported Dialects

Draft 2020-12 Draft 2019-09 Draft 7 Draft 6 Draft 4


Important

We are working hard to get Blaze to its first stable release. This includes:

  • Improving the documentation to include a basic getting started guide
  • Support running the validator on simdjson
  • Bindings to higher-level programming languages, starting with Node.js
  • Publishing an academic paper along with a reproducible benchmark
  • Landing various other in-progress optimizations

Please star the project to show us your support!

Features

  • Performance: Blaze compiles JSON Schema into a lower-level intermediate language for ultra fast evaluation. It can achieve schema validation in the nano-second range, making it a perfect fit for low-latency gateways and validation of large datasets

  • Compliance: Blaze achieves a 100% compliance score in the official Bowtie benchmark, while popular validators like AJV only achieve an average 85% compliance. Furthermore, Blaze is built and maintained by a JSON Schema TSC member

  • Extensibility: Blaze supports the implementation of custom vocabularies of arbitrary complexity, and the ability to setup custom resolution of external schemas from arbitrary sources, like from HTTP, filesystem, databases, etc

  • Annotations: Blaze is one of the few implementations that fully supports annotation extraction during evaluation to augment instances with semantic information, making it a great fit for data science scenarios

Example

Blaze is designed to be easy to use, while at the same time providing extensive hooks for supporting custom vocabularies, resolving external schemas, and more.

// (1) Get a JSON Schema
const auto schema{sourcemeta::jsontoolkit::parse(R"JSON({
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string"
})JSON")};

// (2) Compile the JSON Schema into an optimised representation
const auto compiled_schema{sourcemeta::blaze::compile(
  schema,

  // These options allow you tweak how Blaze works,
  // the JSON Schema vocabularies it understands,
  // and how to resolve references to external schemas
  sourcemeta::jsontoolkit::default_schema_walker,
  sourcemeta::jsontoolkit::official_resolver,
  sourcemeta::blaze::default_schema_compiler,

  // Fast validation means getting to a boolean result
  // as fast as possible. Check out the documentation
  // for how to get detailed error information and/or
  // collect JSON Schema annotations
  sourcemeta::blaze::Mode::FastValidation)};

// (3) Get a JSON instance
const sourcemeta::jsontoolkit::JSON instance{"Hello Blaze!"};

// (4) Validate the instance against the schema
const auto result{sourcemeta::blaze::evaluate(compiled_schema, instance)};
if (result) {
  std::cout << "Success!\n";
}

Documentation

Refer to the project website for documentation and tutorials: https://blaze.sourcemeta.com.

About

The ultra high-performance JSON Schema validator, providing validation in the nano-second range, along with perfect compliance scores. Supports Draft 4, Draft 6, Draft 7, 2019-09 and 2020-12. For both servers and embedded devices

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Languages