def uncomment_json(lines):
    new_lines = []
    for line in lines:
        if '//' in line:
            if '"' in line or "'" in line:
                single_quote_open = False
                double_quote_open = False
                previous_slash    = False
                counter           = 0
                comment_found     = False
                last_c = ''
                for c in line:
                    if c == '/':
                        if previous_slash and not single_quote_open and not double_quote_open:
                            comment_found = True
                            break # counter is the previous one
                        previous_slash = True
                    else:
                        previous_slash = False
                    if c == '"' and last_c != '\\':
                        double_quote_open = not double_quote_open
                    if c == "'" and last_c != '\\':
                        single_quote_open = not single_quote_open

                    last_c = c
                    counter += 1

                if comment_found:
                    new_lines.append(line[:counter - 1] + '\n')
                else:
                    new_lines.append(line)
            else:
                new_lines.append(line.split('//')[0])
        else:
            new_lines.append(line)
    return new_lines
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/admin/script/creation.py/uncomment_json/original