From bfb97a55a2b27e515f42a708f9b4be85f515005c Mon Sep 17 00:00:00 2001 From: Vinaykumar Patel Date: Mon, 27 Aug 2018 14:58:32 +0530 Subject: [PATCH] Added function remove_json_key This will remove the specified JSON key from JSON. Till not we had only "set_json_value". --- src/HttpLibrary/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/HttpLibrary/__init__.py b/src/HttpLibrary/__init__.py index ae11328..f4b345a 100644 --- a/src/HttpLibrary/__init__.py +++ b/src/HttpLibrary/__init__.py @@ -621,7 +621,16 @@ def log_json(self, json_string, log_level='INFO'): for line in json.dumps(json_string, indent=2, ensure_ascii=False).split('\n'): logger.write(line, log_level) - # debug + @_with_json + def remove_json_key(self, json_string, json_pointer): + """ + Remove the target key of the JSON document `json_string` specified by + JSON Pointer `json_pointer` to `json_value`. + + Example: + | ${result}= | Remove Json Key | {"foo": {"bar": [1,2,3]}} | /foo/bar | + """ + return jsonpatch.apply_patch(json_string, [{'op': 'remove','path': json_pointer}]) def show_response_body_in_browser(self): """