Skip to content

Instantly share code, notes, and snippets.

@LouisdeBruijn
Created December 31, 2020 10:27
Show Gist options
  • Select an option

  • Save LouisdeBruijn/d6df0a2590673ef7b83cf1a3ade0a2d5 to your computer and use it in GitHub Desktop.

Select an option

Save LouisdeBruijn/d6df0a2590673ef7b83cf1a3ade0a2d5 to your computer and use it in GitHub Desktop.
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