def merge_json(input_jsons, merge_uri_and_jsons, input_path, removeElements): for x in input_jsons: input_json = x break for merge_uri_and_json in merge_uri_and_jsons: uri_and_jsons = [] for x in merge_uri_and_json: uri_and_jsons.append(x) for uri_and_json in uri_and_jsons: input_json = JSONUtil.replace_values_at_path(input_json, input_path, uri_and_json[0], uri_and_json[1], removeElements) return input_json
def merge_json(input_jsons, merge_uri_and_jsons, input_path): for x in input_jsons: input_json = x break # B/cluster [ # [ # ["C", {"image": {"isSimilarTo": [{"isSimilarTo": {"uri": "I5"}}, {"isSimilarTo": {"uri": "I6"}}]}, "uri": "C"}], # ["B", {"image": {"isSimilarTo": [{"isSimilarTo": {"uri": "I1"}}, {"isSimilarTo": {"uri": "I3"}}, {"isSimilarTo": {"uri": "I5"}}]}, "uri": "B"}] # ] # ] for merge_uri_and_json in merge_uri_and_jsons: uri_and_jsons = [] for x in merge_uri_and_json: uri_and_jsons.append(x) for uri_and_json in merge_uri_and_json: input_json = JSONUtil.replace_values_at_path(input_json, input_path, uri_and_json[0], uri_and_json[1], []) return input_json