YAPI导出json文件,数据解析重组

YAPI导出json文件,数据解析重组_第1张图片

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"]
            }
            # 头部数据解析

你可能感兴趣的:(Django,+,vue,接口自动化测试平台,json,yapi,java)