Skip to content

Fix JSON encoding of custom column headers - #987

Open
dajiaohuang wants to merge 1 commit into
dalance:masterfrom
dajiaohuang:fix/json-custom-header-20261015
Open

dajiaohuang wants to merge 1 commit into
dalance:masterfrom
dajiaohuang:fix/json-custom-header-20261015

Conversation

@dajiaohuang

Copy link
Copy Markdown

Problem

[[columns]] header accepts arbitrary strings, but --json interpolates the header without JSON escaping. For example, a supported configuration containing:

[[columns]]
kind = "Pid"
header = 'Process "ID"'

produces a field like "Process "ID"": 201, so a JSON consumer cannot parse the output. Backslashes and control characters in custom headers have the same problem.

Change

JSON-encode the header with serde_json, retaining existing numeric/string value handling and the default key names. Declare the dependency directly so this also works with --no-default-features (the default Docker dependency already brings it into Cargo.lock). Add a platform-independent regression for ordinary headers, quotes, backslashes, newlines and tabs.

Validation

  • Regression passes with default features and --no-default-features on Windows x86_64, Rust 1.98.1.
  • A local synthetic-record harness exercised production columns and View::filter/adjust/display: the quoted-header JSON failed on base and passes with this change. No host process table was collected.
  • Existing JSON object and regex tests pass in both feature configurations; cargo fmt -- --check passes.
  • cargo clippy -- -D warnings fails on five existing unnecessary casts in src/columns/priority.rs:140–144; the unchanged base has identical diagnostics, with and without default features.
  • Full process-collecting tests and interactive/live-OS acceptance were not run in this shared environment. Synthetic rendering tests do not establish OS collector acceptance.

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.

1 participant