0

我正在寻找一个用于加载 JSON Schema 文件并将其作为对象处理的 Python 模块。我可以通过常规json模块和 eg来做到这一点dictor,但我希望找到一个 JSON Schema 特定模块,例如可以本机理解dependenciesdefinitions类似概念,提供更容易处理数据。

需要明确的是,我不是在寻找 JSON Schema 验证工具,而是在寻找 JSON Schema 对象管理器。这样的事情存在吗?

为了说明我要进行的处理类型,请参见下文:

def schema_lister(device,schema, path):
    path_conf = Path(__file__).resolve().parent.parent
    schema_dir = f"_static/tmp/{device}_schema.json"
    path_schema = Path(path_conf,schema_dir)

    with open(path_schema) as json_file:
        schema_json = json.load(json_file)
        json_file.close()

    schema = dictor(schema_json,path)

    for elm in schema:
        elm_schema = dictor(schema,elm)
        if elm != 'anyOf' and elm != 'dependencies' and isinstance(elm_schema, dict):
            # do things, e.g. print title, description etc.

4

2 回答 2

0

您可以在此处找到 JSON Schema 编辑器列表。在同一页面上是可以将模式转换为类定义的应用程序列表,反之亦然。

于 2020-04-19T23:01:39.163 回答
0

我最终sphinx-jsonschema用于此目的。

于 2020-04-22T11:36:19.273 回答