Created
December 31, 2020 10:27
-
-
Save LouisdeBruijn/d6df0a2590673ef7b83cf1a3ade0a2d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def unescape_html_wrapper(json_data): | |
| """Escapes HTML entities from strings in data to be saved in JSON format. | |
| :param json_data: The data that is going to be saved in JSON format. | |
| :type json_data: list | |
| :return: The data with HTML entities unescaped | |
| :rtype: list | |
| """ | |
| if isinstance(json_data, list): | |
| for idx, elem in enumerate(json_data): | |
| if isinstance(elem, str): | |
| json_data[idx] = unescape_html(elem) | |
| elif isinstance(elem, dict): | |
| for key, value in elem.items(): | |
| if isinstance(value, str): | |
| elem[key] = unescape_html(value) | |
| return json_data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment