Skip to content

Small warning to every user #3

@Arcitec

Description

@Arcitec

Edit: SEE NEXT COMMENT IN THIS ISSUE FOR PROPER SOLUTION.


This library is fine for basic parsing, but it's not a proper parser. It's a basic regex.

regex = re.compile(r"(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*$)", re.MULTILINE | re.DOTALL)
newline_replace_regex = re.compile("\n{2,}", re.MULTILINE)

This basic regex means that it fails on things like this:

{
/* Commented out
"data": "foo */ bar",
*/
}

Because it doesn't understand things like */ inside of data fields, or escaped letters like \*/.

So don't rely on this package for critical production use. But it's fine for basic little scripts.

Edit: In fact it doesn't even handle escaped quotes inside strings, such as "hello \"user\"". So use this library at your own risk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions