Closed Bug 2055774 Opened 1 month ago Closed 1 month ago

JSON Viewer: support JSON Lines (JSONL/NDJSON) documents

Categories

(DevTools :: JSON Viewer, enhancement, P3)

enhancement

Tracking

(relnote-firefox 155+, firefox155 fixed)

RESOLVED FIXED
155 Branch
Tracking Status
relnote-firefox --- 155+
firefox155 --- fixed

People

(Reporter: benoit.goupilleau, Assigned: benoit.goupilleau)

References

Details

Attachments

(7 files)

The JSON Viewer currently only handles application/json. This adds support for JSON Lines documents (one JSON value per line) served as application/jsonlines / application/x-ndjson, or as .jsonl files.

  • Sniff JSONL/NDJSON content and register the stream converter (Sniffer.sys.mjs, converter-child.js, components.conf), exposing JSONView.isJsonl.
  • Parse the document line-by-line into ordered, independently collapsible entries keyed by real file line number (blank lines skipped), via parseJsonl in json-viewer.mjs and jsonl-utils.mjs.
  • Render lines that aren't valid JSON as inline errors (JsonlLineError) without blocking the rest of the document (JsonPanel.mjs).
  • Restore the original content type on Save-As, plus docs and browser-chrome test coverage in browser_jsonview_jsonl.js.
Assignee: nobody → benoit.goupilleau
Status: NEW → ASSIGNED

Hello Benoit, thanks for filing the bug
I guess it has the same goal as Bug 1418633 ?

Whiteboard: [devtools-triage]

(In reply to Nicolas Chevobbe [:nchevobbe] from comment #5)

Hello Benoit, thanks for filing the bug
I guess it has the same goal as Bug 1418633 ?

No. It addresses a different type of data/file format: json lines (.jsonl)

You need to handle pretty print, e.g. data:application/jsonlines,[1,2,3]%0A{"foo":"bar"} becomes

{
  "1": [
    1,
    2,
    3
  ],
  "2": {
    "foo": "bar"
  }
}

(In reply to Nicolas Chevobbe [:nchevobbe] from comment #5)

I guess it has the same goal as Bug 1418633 ?

Actually it's the same as bug 1603986.

(In reply to Oriol Brufau [:Oriol] from comment #8)

(In reply to Nicolas Chevobbe [:nchevobbe] from comment #5)

I guess it has the same goal as Bug 1418633 ?

Actually it's the same as bug 1603986.

It does also cover that format indeed.

(In reply to Oriol Brufau [:Oriol] from comment #7)

You need to handle pretty print, e.g. data:application/jsonlines,[1,2,3]%0A{"foo":"bar"} becomes

{
  "1": [
    1,
    2,
    3
  ],
  "2": {
    "foo": "bar"
  }
}

I am not sure I understand. Currently it displays the example provided as in Screenshot 2026-07-20 at 09.22.40.png

Go to Raw Data, then use Pretty Print.

Priority: -- → P3
Whiteboard: [devtools-triage]

(In reply to Benoit from comment #11)

(In reply to Oriol Brufau [:Oriol] from comment #7)

You need to handle pretty print, e.g. data:application/jsonlines,[1,2,3]%0A{"foo":"bar"} becomes

{
  "1": [
    1,
    2,
    3
  ],
  "2": {
    "foo": "bar"
  }
}

I am not sure I understand. Currently it displays the example provided as in Screenshot 2026-07-20 at 09.22.40.png

it now handles pretty print correctly

Attachment #9617285 - Attachment description: Bug 2055774 - Handle pretty print of jsonl files r=#devtools-reviewers → Bug 2055774 - Hide the Pretty Print button for JSONL documents in the JSON Viewer r=#devtools-reviewers
Attachment #9610032 - Attachment description: Bug 2055774 - Add Save-As coverage and docs for JSON Viewer JSONL support r=#devtools-reviewers → Bug 2055774 - Document JSON Viewer JSONL support r=#devtools-reviewers
Pushed by nchevobbe@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a4e1189c40c6 https://hg.mozilla.org/integration/autoland/rev/14f9cf3dc34d Detect JSONL/NDJSON content and register its stream converter in the JSON Viewer r=devtools-reviewers,nchevobbe https://github.com/mozilla-firefox/firefox/commit/fa581ca58fc1 https://hg.mozilla.org/integration/autoland/rev/d74e288e47e9 Parse JSON Lines documents line-by-line in the JSON Viewer r=devtools-reviewers,nchevobbe https://github.com/mozilla-firefox/firefox/commit/73a45282103f https://hg.mozilla.org/integration/autoland/rev/aee51b0ff455 Render invalid JSONL lines as inline errors in the JSON Viewer r=devtools-reviewers,nchevobbe https://github.com/mozilla-firefox/firefox/commit/db1301d2bc20 https://hg.mozilla.org/integration/autoland/rev/75b28caf059f Document JSON Viewer JSONL support r=devtools-reviewers,nchevobbe https://github.com/mozilla-firefox/firefox/commit/85799112a910 https://hg.mozilla.org/integration/autoland/rev/cba8d07f81c4 Hide the Pretty Print button for JSONL documents in the JSON Viewer r=devtools-reviewers,nchevobbe
See Also: → 1627339
Duplicate of this bug: 1603986
Depends on: 2060529

Did you want to nominate this for the Fx155 relnotes? If so, set the relnote-firefox flag to "?"
https://wiki.mozilla.org/Release_Management/Release_Notes_Nomination

Possible wording:

The JSON Viewer now displays JSON Lines (JSONL/NDJSON) documents, including inline errors for invalid lines.

Flags: needinfo?(nchevobbe)

Release Note Request (optional, but appreciated)
[Why is this notable]:
[Affects Firefox for Android]:
[Suggested wording]:
[Links (documentation, blog post, etc)]:

(In reply to Ryan VanderMeulen [:RyanVM] from comment #19)

Did you want to nominate this for the Fx155 relnotes? If so, set the relnote-firefox flag to "?"
https://wiki.mozilla.org/Release_Management/Release_Notes_Nomination

Sure

Possible wording:

The JSON Viewer now displays JSON Lines (JSONL/NDJSON) documents, including inline errors for invalid lines.

Yeah, looks good to me, thanks!

relnote-firefox: --- → ?
Flags: needinfo?(nchevobbe)

Added to the Fx155 relnotes.

Blocks: 2060972
QA Whiteboard: [qa-triage-done-c156/b155]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: