Add display_name field to Author JSON output#8
Merged
drpedapati merged 1 commit intomainfrom Mar 20, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pubmed fetch --jsonreturns 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 theAuthorstruct 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_namefield to theAuthorstruct, populated viaFullName()at parse time:{"last_name": "Pedapati", "fore_name": "Ernest V", "initials": "EV", "display_name": "Ernest V Pedapati", "affiliation": "..."}display_name=collective_name)Test plan
go test ./...passespubmed fetch 41659484 --json | jq '.[] .authors[0].display_name'returns"Peyton Siekierski"Generated with Claude Code