Skip to content

Fix: wrap list JSON output in array for parseable output - #80

Open
Jah-yee wants to merge 1 commit into
MercuryTechnologies:mainfrom
Jah-yee:fix-wrap-json-list-output
Open

Fix: wrap list JSON output in array for parseable output#80
Jah-yee wants to merge 1 commit into
MercuryTechnologies:mainfrom
Jah-yee:fix-wrap-json-list-output

Conversation

@Jah-yee

@Jah-yee Jah-yee commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Fixes mercury-cli issue #70.

When running commands like mercury accounts list --format json, multiple pretty-printed JSON objects were emitted back-to-back without an enclosing array or commas, making output unparseable by standard JSON parsers:

{"id": "...", "name": "..."}
{"id": "...", "name": "..."}

This change wraps JSON/pretty formatted list output in a proper JSON array with commas between items:

  • Non-pager path: Prepends [\n, appends ,\n]\n to collected output
  • Pager path: Writes [\n, emits items with ,\n separators, writes \n]\n

Before: {...}{...} (unparseable)
After: [{...},{...}] (valid JSON array)

Closes #70

@Jah-yee

Jah-yee commented Jun 1, 2026

Copy link
Copy Markdown
Author

Fix Explanation

Bug: mercury accounts list --format json emitted multiple pretty-printed JSON objects concatenated without array brackets or commas, making output unparseable by standard JSON parsers.

Root cause: ShowJSONIterator in pkg/cmd/cmdutil.go collected formatted JSON for each item and concatenated them directly without wrapping.

Solution: Modified ShowJSONIterator to wrap JSON/pretty formatted list output in a proper JSON array with comma separators between items:

  • Non-pager: prepends [\n, appends ,\n]\n
  • Pager: writes [\n before streaming, ,\n between items, \n]\n after

This likely fixes all list endpoints that use the same ShowJSONIterator pattern.

@Jah-yee

Jah-yee commented Jun 16, 2026

Copy link
Copy Markdown
Author

👋 Hi! Just checking in — this PR has been open 14+ days with no review. Happy to make any adjustments if needed! 🙏

@Jah-yee

Jah-yee commented Jul 6, 2026

Copy link
Copy Markdown
Author

👋 Hi! Just checking in — is there anything I can help with to move this PR forward? Happy to address any feedback! 🙏

@Jah-yee

Jah-yee commented Jul 13, 2026

Copy link
Copy Markdown
Author

Hi @ALL, gentle reminder that this PR is waiting for review. Happy to make any changes — just let me know! 🙏

@Jah-yee

Jah-yee commented Aug 6, 2026

Copy link
Copy Markdown
Author

Friendly ping — any updates? Happy to address feedback.

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.

accounts list --format json emits concatenated objects, not a JSON array

1 participant