jsonschema 0.4.2

A crate for performing JSON schema validation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use serde_json::{from_str, Value};
use std::collections::HashMap;

pub(crate) type ContentMediaTypeCheckType = fn(&str) -> bool;

pub(crate) fn is_json(instance_string: &str) -> bool {
    from_str::<Value>(instance_string).is_ok()
}

lazy_static::lazy_static! {
    pub(crate) static ref DEFAULT_CONTENT_MEDIA_TYPE_CHECKS: HashMap<&'static str, ContentMediaTypeCheckType> = {
        let mut map: HashMap<&'static str, ContentMediaTypeCheckType> = HashMap::with_capacity(1);
        map.insert("application/json", is_json);
        map
    };
}