Files
bun.sh/test/cli
Claude Bot 46288ee202 feat: implement --json flag for JSON output format
- Add --json boolean flag that modifies output format to JSON
- Works with --print: outputs expression result as JSON
- Works with --eval: acts like --print but outputs JSON
- Supports capturing module exports for main modules (CommonJS/ESM)
- Uses jsonStringify for proper JSON serialization
- Handles all JavaScript types including promises, dates, objects, arrays
- Shows error messages for non-serializable types (BigInt, circular refs)

Test results:
  bun --print '42' --json              # outputs: 42
  bun --print '({x: 1})' --json        # outputs: {"x":1}
  bun --eval '({x: 1})' --json         # outputs: {"x":1}
  bun --eval 'null' --json             # outputs: null
  bun --eval 'undefined' --json        # outputs: (nothing)

Includes comprehensive tests covering all data types and edge cases.
2025-09-29 11:31:42 +00:00
..
2025-05-24 13:36:51 -07:00
2025-09-27 00:45:29 -07:00
2025-09-25 23:47:46 -07:00