sql-ddl-to-json-schema 0.2.1

Parse MySQL and MariaDB DDL into a compact table model and JSON Schema draft-07 documents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Small helpers shared by the compact models.

use serde_json::Value;

/// Read a string field from a JSON object.
pub fn get_str<'a>(v: &'a Value, key: &str) -> Option<&'a str> {
    v.get(key).and_then(Value::as_str)
}

/// Whether a JSON value counts as defined: present and not null.
pub fn is_defined(v: Option<&Value>) -> bool {
    matches!(v, Some(x) if !x.is_null())
}