Modern JSON not displayed well in Firefox
Categories
(DevTools :: JSON Viewer, enhancement, P3)
Tracking
(Not tracked)
People
(Reporter: u429623, Unassigned)
Details
Attachments
(1 file)
1.57 KB,
application/json
|
Details |
Firefox has a nice feature of providing a parsed view of a *.json file by default. However, it only handles "traditional" json, where there is only one json object per file.
Many services now work with "documents" where each line is a separate JSON object. Firefox detects a syntax-error on line 2 column 1 (the start of the 2nd object), and refuses to display anything beyond the error message.
It would be a big improvement if one or more of the following enhancements to the default JSON display could be made:
- display the first JSON object (if complete), and then the error message
- support multi object json files (used by AWS Athena and other services)
- support the enhanced JSON derivatives that are gaining popularity, such as Microsoft's JSONC or JSON5
woops -- just saw that this is controlled by config item devtools.jsonview.enabled
(which defaults to true
). Moving to devtools
Comment 2•4 years ago
|
||
- support multi object json files (used by AWS Athena and other services)
- support the enhanced JSON derivatives that are gaining popularity, such as Microsoft's JSONC or JSON5
They should not have taken over application/json mime types...
Comment 3•4 years ago
|
||
Thanks for the report. I like the ideas.
They should not have taken over application/json mime types...
What do you mean by this?
Btw. do you have a link (a test case) to a service providing multi object json file?
Honza
(In reply to Jan Honza Odvarko [:Honza] (always need-info? me) from comment #3)
They should not have taken over application/json mime types...
What do you mean by this?
I suspect he would prefer that the new format use a new mime-type. But I believe this case falls under the "Postal Principle"
Btw. do you have a link (a test case) to a service providing multi object json file?
Yes, but they all require authentication :(. I've sanitized such a file and attached it.
Comment 5•4 years ago
|
||
These are not JSON. They are supersets of JSON, and thus don't have a JSON mime type:
- JSON5 uses
application/json5
- Newline Delimited JSON uses
application/x-ndjson
(see bug 1603986)
Right now the JSON Viewer in Firefox uses JSON.parse()
, so it can't parse them. They would require a custom parser.
Comment 6•4 years ago
|
||
(In reply to Oriol Brufau [:Oriol] from comment #5)
These are not JSON. They are supersets of JSON, and thus don't have a JSON mime type:
I am relieved to hear that.
We learned that Postel's law is harmful, at least about HTML, CSS, and JavaScript. HTML5 defines all error handling explicitly.
These are not JSON. They are supersets of JSON, and thus don't have a JSON mime type:
- JSON5 uses
application/json5
- Newline Delimited JSON uses
application/x-ndjson
(see bug 1603986)
In theory, the above may be true. However, at least one of the thundering herd of cloud providers defaults to plain old json in practice, based on the file extension (headers as rendered by the json viewer):
Content-Disposition inline
Content-Length 9170
Content-Type application/json
...
Server AmazonS3
Mime types in the real world are often a real mess, so it's up to the developer to make a choice. Declare an error & discard everything, or degrade gracefully and consider alternatives that may add value. I see the context here as being "support a web developer in understanding why that upstream 3rd party payload caused their code to crash in the browser".
Comment 8•2 years ago
•
|
||
This looks like a duplicate, can we close in favor of bug 1603986?
Comment 9•2 years ago
|
||
Agree, thank you for the ping here.
Description
•