欢迎来到BlackTest-老王自动化测试

YAPI解析 根据需求自行扩展

import json

# 数据路径
path = "e:\\yapi2.json"

# 读取文件数据
with open(path, "r", encoding='utf-8') as f:
    row_data = json.load(f)

yapi_list = []

# 读取每一条json数据
for d in row_data[0]['list']:
    req_body_other = {}
    if d.get("req_body_other") is None:
        req_body_other = {}

    else:
        body = json.loads(d.get("req_body_other"))
        if body.get('properties'):
            for k in body['properties'].keys():
                req_body_other[k] = ""

            print(req_body_other)

    yapi_dict = {
        "api_title": d['title'],
        "body": req_body_other

    }

    yapi_list.append(yapi_dict)

print(yapi_list)

  

posted @ 2022-07-14 19:58  BlackTest  阅读(204)  评论(0编辑  收藏  举报