Firefox throws error in parsing perfectly sane JSON
Categories
(DevTools :: JSON Viewer, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: yuilytg7, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0
Steps to reproduce:
If you connect to this website:
http://abel.lis.illinois.edu/cgi-bin/ethnea/search.py?Fname=Jos%C3%A9&Lname=Svensson&format=json
it will return you the following JSON:
{'Genni': 'M', 'Ethnea': 'NORDIC-HISPANIC', 'Last': 'Svensson', 'First': 'JosA'}
This looks like a perfectly sane JSON, but Firefox throws an error when parsing it:
SyntaxError: JSON.parse: expected property name or '}' at line 1 column 2 of the JSON data
Actual results:
Firefox throws error when parsing JSON
Expected results:
The JSON should be parsed without errors since it is perfectly sane
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'DevTools::General' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•3 years ago
|
||
JSON standard doesn't accept single quotes, that's why the parsing fails for this example (see https://www.json.org).
Some potential actions on this:
- show the "Raw Data" tab by default when JSON parsing fails, instead of the JSON tab?
- provide better error messages for common mistakes (thinking about: single quotes, missing quotes, trailing coma)
I would not make the parsing more flexible (and accept any object-looking data), because if a server thinks it's serving JSON, it's important to tell the user quickly whether there's something wrong with this or not. Because any application or third party which consumes this incorrect json will most likely not accept it.
Updated•3 years ago
|
Comment 3•3 years ago
|
||
Discussed in triage session, we could default to raw data for invalid JSOn, but still show a warning notification.
Comment 4•2 years ago
|
||
(In reply to Julian Descottes [:jdescottes] from comment #3)
Discussed in triage session, we could default to raw data for invalid JSOn, but still show a warning notification.
If opting for this solution, could we close in favor of bug 1764897?
Comment 5•2 years ago
•
|
||
provide better error messages for common mistakes (thinking about: single quotes, missing quotes, trailing coma)
Alternatively, this second idea links up well with bug 1198558.
Comment 6•2 years ago
|
||
(In reply to Zachary Svoboda :zacnomore from comment #4)
(In reply to Julian Descottes [:jdescottes] from comment #3)
Discussed in triage session, we could default to raw data for invalid JSOn, but still show a warning notification.
If opting for this solution, could we close in favor of bug 1764897?
Good point, we missed triaging the other bug because it was filed as an enhancement :(
Let's close as duplicate and add a reference to bug 1198558.
Description
•