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

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

~2.5–3.5MB
~63K SLoC