【发布时间】:2020-04-19 12:51:36
【问题描述】:
我正在寻找用于加载 JSON 模式文件并将其作为对象处理的 Python 模块。我可以通过常规的json 模块来做到这一点,例如dictor,但我希望找到一个 JSON Schema 特定模块,例如原生理解dependencies、definitions等类似概念,提供更轻松的数据处理。
明确地说,我不是在寻找 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.
【问题讨论】:
标签: python jsonschema python-jsonschema