Feature request: Pretty print JSON by default

RESOLVED DUPLICATE of bug 1243951

Status

P3
normal
RESOLVED DUPLICATE of bug 1243951
3 years ago
3 months ago

People

(Reporter: tantek, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [btpp-backlog] )

(Reporter)

Description

3 years ago
When showing a JSON document, e.g. browse to:

http://xray.p3k.io/parse?url=http%3A%2F%2Ftantek.com%2F2016%2F056%2Ft1%2Findieweb-published-video-automatically-possed

The browser should render it pretty-printed by default, e.g. more like:

http://xray.p3k.io/parse?url=http%3A%2F%2Ftantek.com%2F2016%2F056%2Ft1%2Findieweb-published-video-automatically-possed&pretty=true

Filing in DevTools since it seems DevTools already has code to pretty print JSON (as evidenced by bug 1218471).

Users would still be able to access the "raw" JSON via "View Source".

However developers nearly always prefer to see pretty-printed JSON to figure out what the JSON is saying/doing, hence pretty-printing should be the default display, and would be another nice bit of polish for web developers.
There is a nice JSON Viewer tool on the way, which I believe meets these needs.  You can try it in Nightly by flipping "devtools.jsonview.enabled".

I'll mark this as a duplicate of the bug to enabled it on all channels, but please reopen if that's not quite what you meant.
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Component: Developer Tools → Developer Tools: JSON Viewer
Resolution: --- → DUPLICATE
Duplicate of bug: 1243951
(Reporter)

Comment 2

3 years ago
The existence of a tool does not meet these user needs.

In particular, from the title: "by default" is the key.

It is great that there is a nice JSON Viewer tool on the way, that should mean it can be called to:

programmatically automatically upon the browser loading a JSON document <-- and that's the key missing piece.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
(In reply to Tantek Çelik from comment #2)
> The existence of a tool does not meet these user needs.
> 
> In particular, from the title: "by default" is the key.
> 
> It is great that there is a nice JSON Viewer tool on the way, that should
> mean it can be called to:
> 
> programmatically automatically upon the browser loading a JSON document <--
> and that's the key missing piece.

I am not sure what you mean...  The JSON Viewer appears in the main contain area and takes over the display of JSON content when enabled.  It also has a raw mode to still access the original.

So, it does appear "automatically upon the browser loading a JSON document".
Flags: needinfo?(tantek)
Priority: -- → P3
Whiteboard: [btpp-backlog]
WFM in nightly. If bug 1243951 extends this to "all channels" it seems to tick all the boxes here.
Status: REOPENED → RESOLVED
Last Resolved: 3 years ago3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1243951
(Reporter)

Comment 5

3 years ago
Verified in 47.0a2 that the JSON viewer appears by default - nicely done.

Would be nice if there was a way to "expand all" instead of having to twiddle each triangle to expand each object one by one, just as a "pretty printed" version (e.g. link in initial report) shows the entire JSON tree. 

I can file that as a separate feature enhancement bug or we can re-open this bug and mark non-duplicate for that specifically (i.e. more like "Pretty print" as the bug title and initial description originally requested).
(Reporter)

Updated

3 years ago
Flags: needinfo?(tantek)
(In reply to Tantek Çelik from comment #5)
> Would be nice if there was a way to "expand all" instead of having to
> twiddle each triangle to expand each object one by one, just as a "pretty
> printed" version (e.g. link in initial report) shows the entire JSON tree. 
> 
> I can file that as a separate feature enhancement bug or we can re-open this
> bug and mark non-duplicate for that specifically (i.e. more like "Pretty
> print" as the bug title and initial description originally requested).

Does the auto-expand feature of bug 1247064 sound like it would address this?
Flags: needinfo?(tantek)
(Reporter)

Comment 7

3 years ago
> Does the auto-expand feature of bug 1247064 sound like it would address this?

Yes it does! Thus the combination of bug 1243951 (JSON viewer by default) and bug 1247064 (auto expand) fully handles this double-duplicate as it were. Thanks much for the follow-ups.
Depends on: 1247064, 1243951
Flags: needinfo?(tantek)

Updated

3 months ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.