#json-schema #inference #input #data #infer #detect #array

infers-jsonschema

A crate for inferring JSON Schema from input data

1 unstable release

0.1.0 Apr 15, 2020

#6 in #infer


Used in jsonst

MIT license

17KB
406 lines

infers-jsonschema

This crate provides JSON Schema inference from input data.

Example:

use infers_jsonschema::infer;
use serde_json::json;

fn main() {
    let data = json!(["foo", "bar"]);
    let schema = infer(&data);
    assert_eq!(
        schema,
        json!({
            "type": "array",
            "items": {"type": "string"},
            "$schema": "http://json-schema.org/draft-07/schema#"
        })
    )
}

Dependencies

~3MB
~60K SLoC