import json
# 数据路径
path = "D:/xxx/xxx/api.json"
# 读取文件数据
with open(path, "r", encoding='utf-8') as f:
yapi_list = json.load(f)
result = []
# 遍历列表数据
for y in yapi_list:
# 父节点
parent = {
"project_name": y["name"],
# 子节点
"children": []
}
if y["list"]:
# 遍历子节点的列表数据
for c in y["list"]:
# 取出想要的数据
children_dict = {
"url": c["query_path"]["path"],
"params": c["req_params"],
"method": c["method"],
"name": c["title"]
}
# 头部数据
YAPI导出json文件,数据解析重组
于 2023-02-25 10:37:52 首次发布