Add %J console format specifier#33036
Add %J console format specifier#33036wltsmrz wants to merge 2 commits intonodejs:masterfrom wltsmrz:console-json-format
Conversation
|
The main question for me in this case where
It is new to me that it's controversial. Do you have a source where this is discussed? I saw the comments in the referenced issue but it did not seem really controversial to me? |
|
Worth a try! I'm not going to argue this one much as the reasons for including %J are obvious, as are the reasons for not including it (not in the spec, bloat-prevention). I believe that |
devsnek
left a comment
There was a problem hiding this comment.
we should only implement standardized specifiers
+1 |
|
I’ll close this, given that consensus appears to be that we should not add non-standard specifiers. Thanks for the pull request, though! |
This pull request adds %J format specifier for printing indented JSON.
I believe there may be some appetite for achieving this without cumbersome
console.log(JSON.stringify(a, null, 2)). Some representative github code searches:"console.log(" "JSON.stringify("3.5mil JS results"console.log(" "%j"1.1mil JS results"console.dir("300k JS resultsActually, now that I look at previous github issues this exact idea was mentioned in #14558. The controversial
%oformat specifier does seem to be getting a lot of use, as far as I can tell with github code search. Thoughts?Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes