def json_remove_comments(text):
def replacer(match):<EOL><INDENT>s = match.group(<NUM_LIT:0>)<EOL>if s.startswith('<STR_LIT:/>'):<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>return s<EOL><DEDENT><DEDENT>pattern = re.compile(<EOL>r'<STR_LIT>',<EOL>re.DOTALL | re.MULTILINE<EOL>)<EOL>return re.sub(pattern, replacer, text)<EOL>
Removes C style comments from the given string. Will keep newline
        characters intact. This way parsing errors from json will point to the
        right line.

        This is primarily used to make comments in JSON files possible.
        The JSON standard has no comments syntax, but we want to use
        JSON for our profiles and configuration files. The comments need to be
        removed first, before the text can be feed to the JSON parser of python.

    @param text: JSON string that should be cleaned
    @type text: string
    @return: Cleaned JSON
    @rtype: string