"""
@autor:Yue
@date::14:04
@file:dealCase.py
@project:appQutoInfo

"""
import json,os,html

def readCaseFile(filename):


    if os.path.getsize(filename)>0:
        try:

            with open(filename,encoding="utf-8",mode='r+') as f:
                #t=html.unescape(f.read())
                #print(t,type(t))
                return json.load(f)
                #return f
        except Exception as e:
            #当f没数据的时候，load也会出错
            print(filename)
            print("读json文件处理出现错误>>",e)
    else:
        raise Exception("json文件为空")

def writeCaseFile(filename,**kwargs):
    try:
        with open(filename, encoding="utf-8",mode="w+") as f:
            for k,v in kwargs.items():
                json.dump(v,fp=f,ensure_ascii=True,indent=3)

    except Exception as e:
        print("json文件处理出现错误>>",e)




if __name__ == '__main__':
    f='/Users/dm/Desktop/python_script/autoInterface/testCase/ces/679.json'
    #t=writeCaseFile(f,1)
    t=readCaseFile(f)
    print(t,type(t))
