NEW 158033
Web Inspector: JSON Parse error message should include more useful details about what caused parsing to fail
https://bugs.webkit.org/show_bug.cgi?id=158033
Summary Web Inspector: JSON Parse error message should include more useful details ab...
Blaze Burg
Reported 2016-05-24 11:43:33 PDT
Currently, an SyntaxError is thrown, but the line and column properties are set to the call site of JSON.parse(). What I really want to know is the string that failed to parse, and where within string parsing failed (approximately). If the parse error says 'invalid number', I would expect to be able to figure out where it died. This is kind of difficult since the argument to JSON.parse is generally not a resource we already have in a text editor, so we'd need to figure out how to display that text (which could be megabytes of JSON).
Attachments
Blaze Burg
Comment 1 2016-05-27 07:18:03 PDT
Ping for import.
Radar WebKit Bug Importer
Comment 2 2016-05-27 07:20:50 PDT
JF Bastien
Comment 3 2016-10-04 16:24:04 PDT
This is pretty bad: jsc -e 'JSON.parse("{\"a\": {},}")' Exception: SyntaxError: JSON Parse error: Property name must be a string literal at [Command Line]:1 parse@[native code] global code@[Command Line]:1:11 Looks like it comes from JSC: Source/JavaScriptCore/runtime/LiteralParser.cpp: m_parseErrorMessage = ASCIILiteral("Property name must be a string literal"); There are some tests for it: LayoutTests/js/dom/JSON-parse-expected.txt:PASS tests[i](nativeJSON) threw exception SyntaxError: JSON Parse error: Property name must be a string literal. LayoutTests/js/dom/JSON-parse-expected.txt:PASS tests[i](nativeJSON) threw exception SyntaxError: JSON Parse error: Property name must be a string literal. I may un-lazy and try to improve it at some point...
Note You need to log in before you can comment on or make changes to this bug.