# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test
# FileName:      read_json.py
# Author:       mwx
# Datetime:     2024/11/5 19:33
# Description:
# 
# ---------------------------------------------------------------------------
import json
import os

from Interface_automation.APIAutoText_v3_1_1 import log


def read_json(file_path):
    log.info(f"读取{file_path}下的json文件中的数据")
    if isinstance(file_path,str) and os.path.isfile(file_path) and file_path.endswith(".json"):
        with open(file_path,mode="r",encoding="utf-8") as f:
            try:
                return json.load(f)
            except Exception as e:
                log.error(f"获取{file_path}下的数据失败，错误类型为{e},检查传入的file_path")
                raise e
    else:
        print(f"获取{file_path}的路径错误")


if __name__ == '__main__':
    r = read_json(r"C:\pycharm\test\Interface_automation\APIAutoText_v3_1_1\data_cofig\mw\case_data.json")
    print(r)