# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   test59
# FileName:      read_json.py
# Author:       laozhao
# Datetime:     2024/3/18 15:26
# Description:
# 
# ---------------------------------------------------------------------------
import json
import os
from InterfaceAutoTest import log_decorator


@log_decorator
def read_json(filename: str):
    if os.path.isfile(filename) and filename.endswith(".json"):
        try:
            with open(filename, mode="r", encoding="utf-8") as fp:
                return json.loads(fp.read())
        except:
            raise IOError("文件内容有错误")
    else:
        raise FileNotFoundError("传入的文件路径错误")
