Skip to content

parser: add a pretty printer for top-level json documents#43702

Merged
TimvdLippe merged 2 commits into
servo:mainfrom
webbeef:json-viewer
Apr 5, 2026
Merged

parser: add a pretty printer for top-level json documents#43702
TimvdLippe merged 2 commits into
servo:mainfrom
webbeef:json-viewer

Conversation

@webbeef

@webbeef webbeef commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

This adds a new resource implementing a simple pretty printer for json documents.

Testing: build this branch and launch with ./mach run https://httpbin.org/json

image

@webbeef webbeef requested a review from gterzian as a code owner March 27, 2026 05:03
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 27, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@webbeef webbeef force-pushed the json-viewer branch 2 times, most recently from 6819856 to 167efe8 Compare March 27, 2026 15:53
@TimvdLippe TimvdLippe self-assigned this Apr 1, 2026

@TimvdLippe TimvdLippe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this PR and had several suggestions. Then I figured it's easier if I open a PR directly on your fork that you can integrate: webbeef#5

Comment thread components/script/dom/servoparser/mod.rs
Comment thread components/default-resources/resources/json-viewer.html
@servo-highfive servo-highfive added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Apr 4, 2026
Signed-off-by: webbeef <me@webbeef.org>
Several improvements:

1. Define helper functions at the top
2. Add initial DOM nodes, so that we don't need to manually
create them and thrash the initial DOM (especially for large
JSON documents)
3. Use `classList` for class toggling
4. Use css nesting for shorter CSS code
5. Use `const` instead of `let`

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: webbeef <me@webbeef.org>

@TimvdLippe TimvdLippe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 5, 2026
@TimvdLippe TimvdLippe added this pull request to the merge queue Apr 5, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 5, 2026
Merged via the queue into servo:main with commit 0b5688f Apr 5, 2026
30 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants