我正在寻找一个Python模块,用于加载JSON模式文件并将其作为对象处理。我可以通过常规的json
模块和dictor
来实现这一点,但我希望找到一个特定于JSON模式的模块,该模块可以本地理解dependencies
、definitions
和类似的概念,提供更简单的数据处理
明确地说,我不是在寻找JSON模式验证工具,而是一个JSON模式对象管理器。这样的东西存在吗
要说明我希望执行的处理类型,请参见以下内容:
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.
为此,我最终使用了
sphinx-jsonschema
您可以找到JSON模式编辑器的列表here。在同一页上有一个应用程序列表,可以将模式转换为类定义,也可以将模式转换为类定义
相关问题 更多 >
编程相关推荐