- for i in range(len(jsonTarget)):
- if (comparejson(jsonTarget[i], jsonResult[i], arrayKey) != 0):
- return 1
+ return True
+
+# Deep compare of two json obects
+# If a parameter value in the target json is set to '????' then the result json value is not checked for the that parameter
+# Return true for equal json, false for not equal json
+def compare_json_obj(obj1, obj2):
+ if isinstance(obj1, list):
+ if (not isinstance(obj2, list)):
+ return False
+ return compare_json_list(obj1, obj2)
+ elif (isinstance(obj1, dict)):
+ if (not isinstance(obj2, dict)):
+ return False
+ exp = set(obj2.keys()) == set(obj1.keys())
+ if (not exp):
+ return False
+ for k in obj1.keys():
+ val1 = obj1.get(k)
+ val2 = obj2.get(k)
+ if isinstance(val1, list):
+ if (not compare_json_list(val1, val2)):
+ return False
+ elif isinstance(val1, dict):
+ if (not compare_json_obj(val1, val2)):
+ return False
+ else:
+ #Do not check parameter values marked with '????'
+ if ((val1 != "????") and (val2 != val1)) and ((val2 != "????") and (val2 != val1)):
+ return False