【发布时间】:2020-03-24 03:38:07
【问题描述】:
我正在尝试找到一个包含关键字的库来帮助我,但没有成功。
我现在正在做的是将每个 JSON 响应转换为字典,然后比较字典,但我讨厌它。
我试图找到类似的库并找到了这个 python 代码,但我不知道如何让这个函数对我有用。
def _verify_json_file(self, result, exp):
'''
Verifies if two json files are different
'''
with open(exp) as json_data:
data = re.sub(ID, ID_REP, json_data.read())
expected = JSON.loads(data)
differences = jsondiff.diff(expected, result, syntax='explicit')
if not differences :
return True
if differences == expected or differences == result:
raise AssertionError("ERROR! Jsons have different structure")
return False
【问题讨论】:
-
澄清你的问题。
标签: json robotframework