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)
标签:body,YAPI,req,list,自行,json,other,yapi,解析 来源: https://www.cnblogs.com/wangyinghao/p/16479123.html