Skip to content

console.json #222

@wmelton

Description

@wmelton

The vast majority of data transmission in today's javascript ecosystem happens via JSON serialized objects. For node.js developers, serializing objects to inspect them is a mainstay of iterative debugging.

However, as many, many objects are nested, being able to easily inspect the entire object in the console is cumbersome.

console.log(JSON.stringify(<serializable>, null, 2)) has been coded more times in my career than I ever want to count lol.

Given the fact that JSON is ubiquitous in 2023, that JS is object-based by default (meaning the majority of object structures are JSON-serializable), and that it would just be insanely useful, helpful to developers, I want to propose that the whatwg console standard be extended to include console.json

In an ideal world, calling console.json() would perform a similar duty as console.log(JSON.stringify(<serializable>, null, 2)) but with a lot less syntax.

An argument to pretty print or not would seem reasonable. If for verbosity sake an argument to limit the depth of iteration was desired, that would be a reasonable argument/ask in my mind.

Otherwise this seems like a straight-forward and immensely helpful standard extension, especially for node.js developers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions