Open clayadavis opened 1 month ago
Implemented a solution in https://github.com/Nykakin/chompjs/pull/65 could you test this branch?
Also note that this library is not meant to fully parse JavaScript language and it only starts at first opening JSON character (either [
or {
) for quick convenience. If your script contains a function, then its {
will be interpreted as opening of JSON and will break the parsing. Sometimes there's no other way but to manually clear your input or use regular expressions to isolate relevant fragment of the script. And if you do that, in many cases using json.loads
directly can suffice.
Using version 1.3.0 installed from pip.
Both of the following fail to parse:
The error is as follows:
This comes up in the wild when JS is stored as CDATA like this: