Skip to content

feat(search): omit zero-value fields from JSON output#52

Merged
rgonek merged 3 commits intomainfrom
feature/search-result-omitempty
Mar 3, 2026
Merged

feat(search): omit zero-value fields from JSON output#52
rgonek merged 3 commits intomainfrom
feature/search-result-omitempty

Conversation

@rgonek
Copy link
Owner

@rgonek rgonek commented Mar 3, 2026

Summary

  • Add json:"field,omitempty" tags to all Document and SearchResult fields
  • Change Document.ModTime from time.Time to *time.Time so nil is serialized as omitted (not "0001-01-01T00:00:00Z")
  • Zeroed-out fields from result_detail: minimal or standard presets now cleanly disappear from JSON output

Before / After (minimal preset)

Before:

{"Document":{"ID":"","Type":"","Path":"DEV/foo.md","PageID":"","Title":"","SpaceKey":"","Labels":null,"Content":"","HeadingPath":["## H2"],"HeadingText":"H2","HeadingLevel":0,"Language":"","Line":12,"ModTime":"0001-01-01T00:00:00Z"},"Score":0,"Snippet":"...match..."}

After:

{"document":{"path":"DEV/foo.md","heading_path":["## H2"],"heading_text":"H2","line":12},"snippet":"...match..."}

Test Plan

  • go test ./... — all packages pass
  • conf search "term" --result-detail minimal --format json — verify only path/heading/line/snippet present

🤖 Generated with Claude Code

Robert Gonek and others added 3 commits March 3, 2026 15:03
Add json omitempty tags to Document and SearchResult fields.
Change ModTime to *time.Time so nil is omitted rather than
printing the zero time "0001-01-01T00:00:00Z" in minimal/standard
result_detail presets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rgonek rgonek merged commit 60e28b9 into main Mar 3, 2026
2 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.

1 participant