json_schema_ast 0.2.2

JSON Schema Compatibility Checker
Documentation

json_schema_ast

JSON Schema AST and reference resolver.

crates.io docs.rs License: MIT

Installation

Add to your Cargo.toml:

[dependencies]
json_schema_ast = "0.2.1"

Usage

use json_schema_ast::{build_and_resolve_schema, compile, SchemaNode, JSONSchema};
use serde_json::json;

let raw = json!({
    "type": "object",
    "properties": {
        "id": { "type": "integer" },
        "name": { "type": "string" }
    },
    "required": ["id"]
});

// Build AST
let schema_node: SchemaNode = build_and_resolve_schema(&raw).unwrap();

// Compile a fast validator
let validator: JSONSchema = compile(&raw).unwrap();

// Validate instances
assert!(validator.is_valid(&json!({ "id": 42 })));

License

Licensed under MIT. See LICENSE.