Closed Bug 1748039 Opened 3 years ago Closed 2 years ago

Firefox throws error in parsing perfectly sane JSON

Categories

(DevTools :: JSON Viewer, enhancement, P3)

Firefox 95
enhancement

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1764897

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

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.

Component: Untriaged → General
Product: Firefox → DevTools

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.

Component: General → JSON Viewer

Discussed in triage session, we could default to raw data for invalid JSOn, but still show a warning notification.

Type: defect → enhancement
Priority: -- → P3

(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?

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.

(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.

Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.