Skip to content

Feat: JSON Output Support (-format=json)#71

Merged
peczenyj merged 2 commits into
develfrom
feat/json-output
May 28, 2026
Merged

Feat: JSON Output Support (-format=json)#71
peczenyj merged 2 commits into
develfrom
feat/json-output

Conversation

@peczenyj
Copy link
Copy Markdown
Owner

@peczenyj peczenyj commented May 28, 2026

Implemented structured JSON output for both diff and inspect modes as per the v0.7.0 roadmap.

Features

  • New Flag: -format=json (default text) emits machine-readable findings or layouts.
  • Structured Document: Includes tool version, mode, and results.
  • Rich Data: JSON findings include package, file, line, column, sizes, and original/proposed struct source.
  • Precise Layouts: JSON layouts include per-field offsets, sizes, and padding.

Technical Details

  • Added Format enum in pkg/common with enumer support.
  • Updated common.Finding and common.Layout to include a Package field.
  • Implemented RenderJSON in internal/ui/json.go.
  • Integrated JSON rendering into app.Run, suppressing text-only stderr notes in JSON mode.

Follow-up fix (commit 7cd23a4)

  • Make -tags a single global "include tags in output" toggle: inspect JSON now honors the flag instead of always emitting the per-field tag. STRUCTALIGN_TAGS=true and tags = true in .structalignrc work via the existing config layer.

Verified with:

  • Golden file tests in internal/ui/json_test.go (incl. new inspect_notags_tagged.json.golden + inspect_tags_tagged.json.golden).
  • Integration tests in internal/app/json_test.go.
  • Full task ci suite.

Closes #73.

This PR adds structured JSON output for both diff and inspect modes.

- New -format enum flag (text|json).
- Structured JSON document includes tool version, mode, findings/layouts, and summary.
- Populated Package field in Finding and Layout DTOs.
- Golden file tests for JSON output in internal/ui.
- Integration tests in internal/app.
- Documentation updated in README.md and AGENTS.md.
@peczenyj peczenyj self-assigned this May 28, 2026
Make -tags a single global "include tags in output" toggle: previously
inspect JSON always emitted the per-field `tag`, regardless of -tags
(text inspect already gated it). Plumb keepTags into RenderJSON and
clear the field when off; STRUCTALIGN_TAGS=true and `tags = true` in
.structalignrc work via the existing config layer. Closes #73.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@peczenyj peczenyj merged commit ddd3c49 into devel May 28, 2026
6 checks passed
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.

JSON inspect mode: honor -tags flag (currently always emits tag)

1 participant