Skip to content

Add display_name field to Author JSON output#8

Merged
drpedapati merged 1 commit intomainfrom
fix/author-display-name-in-json
Mar 20, 2026
Merged

Add display_name field to Author JSON output#8
drpedapati merged 1 commit intomainfrom
fix/author-display-name-in-json

Conversation

@drpedapati
Copy link
Copy Markdown
Owner

Problem

pubmed fetch --json returns authors as structured objects:

{"last_name": "Pedapati", "fore_name": "Ernest V", "initials": "EV", "affiliation": "..."}

Consumers parsing this JSON must reconstruct a display name manually. The FullName() method exists on the Author struct but is only used for CSV and human output — not JSON. This caused a parse failure in DocsRevise where the literature search expected author strings and got objects.

Fix

Add a display_name field to the Author struct, populated via FullName() at parse time:

{"last_name": "Pedapati", "fore_name": "Ernest V", "initials": "EV",
 "display_name": "Ernest V Pedapati", "affiliation": "..."}
  • Non-breaking: existing consumers see an additional field
  • Handles collective names correctly (display_name = collective_name)
  • 2-line change: one field addition, one assignment at parse time

Test plan

  • go test ./... passes
  • Build succeeds
  • Manual: pubmed fetch 41659484 --json | jq '.[] .authors[0].display_name' returns "Peyton Siekierski"

Generated with Claude Code

The Author struct's JSON output includes structured fields (last_name,
fore_name, initials, affiliation) but no ready-to-use display string.
Consumers parsing --json output had to reconstruct "ForeName LastName"
themselves, and the FullName() method was only used for CSV/human output.

Add display_name field that is populated via FullName() at parse time.
This is non-breaking — existing JSON consumers see an additional field.

Example before:
  {"last_name": "Pedapati", "fore_name": "Ernest V", "initials": "EV"}

Example after:
  {"last_name": "Pedapati", "fore_name": "Ernest V", "initials": "EV",
   "display_name": "Ernest V Pedapati"}

Handles collective names correctly (display_name = collective_name).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@drpedapati drpedapati merged commit ec20190 into main Mar 20, 2026
1 check 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