invalid_escape = re.compile('\\\\[0-7]{1,3}')

def replace_with_byte(match):
    return chr(int(match.group(0)[1:], 8))

def repair(brokenjson):
    return invalid_escape.sub(replace_with_byte, brokenjson)
Исправление недопустимого escape-кода JSON