# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   Selenium_Project
# FileName:      readjson.py
# Author:       xxxxxxx
# Datetime:     2024/5/20 18:55
# Description:
# 命名规范：文件名全小写+下划线，类名大驼峰，方法和变量小写+下划线连接，
# 常量大写，变量和常量用名词，方法用动词
# ---------------------------------------------------------------------------
import json
import os

from api_test_0520 import log_decorator


@log_decorator
def read_json(filename):
    if os.path.isfile(filename) and filename.endswith(".json"):
        try:
            with open(filename, mode="r", encoding="utf-8") as f:
                return json.load(f)
        except Exception as e:
            print(e)
            raise e
    else:
        raise FileNotFoundError("文件路径错误")
