fix(console): implement %j format specifier for JSON output
Merged
RO
1y ago+85+85+01234567890123456789-1-1-0123456789
Summary
- Implements the
%jformat specifier forconsole.logand related console methods %joutputs the JSON stringified representation of the value- Previously,
%jwas not recognized and was left as literal text in the output
Test plan
- Run
bun bd test test/regression/issue/24234.test.ts- all 5 tests pass - Verify tests fail with system Bun (
USE_SYSTEM_BUN=1) to confirm fix validity - Manual verification:
console.log('%j', {foo: 'bar'})outputs{"foo":"bar"}
Example
Before (bug):
$ bun -e "console.log('%j %s', {foo: 'bar'}, 'hello')"
%j [object Object] hello
After (fixed):
$ bun -e "console.log('%j %s', {foo: 'bar'}, 'hello')"
{"foo":"bar"} hello
Closes #24234
š¤ Generated with Claude Code