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)