import json import re import os def fix_json_string(json_str): # Replace single backslashes with double backslashes # but only when they're not already properly escaped return re.sub(r'(?