3 from deepdiff import DeepDiff
6 """JSONUtils is common resource for simple json helper keywords."""
8 def json_equals(self, left, right):
9 """JSON Equals takes in two strings or json objects, converts them into json if needed and then compares them, returning if they are equal or not."""
10 if isinstance(left, basestring):
11 left_json = json.loads(left);
14 if isinstance(right, basestring):
15 right_json = json.loads(right);
19 ddiff = DeepDiff(left_json, right_json, ignore_order=True);
25 def json_escape(self, jsonObject):
26 jsonstr = json.dumps(jsonObject)
27 outstr = jsonstr.replace('"', '\\"').replace('\n', '\\n')
30 def make_list_into_dict(self, listOfDicts, key):
31 """ Converts a list of dicts that contains a field that has a unique key into a dict of dicts """
33 if isinstance(listOfDicts, list):
34 for thisDict in listOfDicts: