{"id":15422577,"url":"https://github.com/heaths/gh-merge-json","last_synced_at":"2026-04-10T08:30:20.915Z","repository":{"id":119951445,"uuid":"610496253","full_name":"heaths/gh-merge-json","owner":"heaths","description":"GitHub CLI extension to merge JSON responses to return valid JSON when passing --paginate to gh api.","archived":false,"fork":false,"pushed_at":"2024-01-10T00:15:44.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-01T10:16:46.049Z","etag":null,"topics":["gh-extension"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heaths.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-06T22:18:37.000Z","updated_at":"2024-01-17T13:22:29.000Z","dependencies_parsed_at":"2024-06-20T15:36:05.962Z","dependency_job_id":"2f027035-81f2-45af-9fb9-cd5759b11654","html_url":"https://github.com/heaths/gh-merge-json","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":"heaths/template-golang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgh-merge-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgh-merge-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgh-merge-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heaths%2Fgh-merge-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heaths","download_url":"https://codeload.github.com/heaths/gh-merge-json/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239979034,"owners_count":19728451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gh-extension"],"created_at":"2024-10-01T17:38:57.932Z","updated_at":"2026-04-10T08:30:20.859Z","avatar_url":"https://github.com/heaths.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Merge JSON from GitHub CLI\n\nA [GitHub CLI](https://github.com/cli/cli) to merge JSON responses to return valid JSON when passing `--paginate` to `gh api`:\n\n```powershell\n$issues = gh api 'repos/{owner}/{repo}/issues' --paginate | gh merge-json | ConvertFrom-Json\n```\n\n## Install\n\nMake sure you have version 2.0 or [newer](https://github.com/cli/cli/releases/latest) of the GitHub CLI installed.\n\n```bash\ngh extension install --force heaths/gh-merge-json\n```\n\nThe `--force` flag I [introduced](https://github.com/cli/cli/pull/7173) in `gh` [version 2.25](https://github.com/cli/cli/releases/tag/v2.25.0)\nto better support automation. It will install or upgrade an extension, or do nothing if the latest extension version is\nalready installed.\n\n## Details\n\nThe GitHub CLI can return paginated JSON responses from both REST and GraphQL APIs;\nhowever, due to bug [#1268](https://github.com/cli/cli/issues/1268) when `--paginate` is passed to `gh api` it does not\nreturn value JSON:\n\n```json\n{\n  \"data\": {\n    \"viewer\": {\n      \"repositories\": {\n        \"nodes\": [\n          {\n            \"nameWithOwner\": \"owner/repo1\"\n          },\n          {\n            \"nameWithOwner\": \"owner/repo2\"\n          }\n        ],\n        \"pageInfo\": {\n          \"hasNextPage\": true,\n          \"endCursor\": \"Y3Vyc29yOnYyOpHOBAaq0A==\"\n        }\n      }\n    }\n  }\n}\n{\n  \"data\": {\n    \"viewer\": {\n      \"repositories\": {\n        \"nodes\": [\n          {\n            \"nameWithOwner\": \"owner/repo3\"\n          },\n          {\n            \"nameWithOwner\": \"owner/repo4\"\n          }\n        ],\n        \"pageInfo\": {\n          \"hasNextPage\": true,\n          \"endCursor\": \"Y3Vyc29yOnYyOpHOBzdvuQ==\"\n        }\n      }\n    }\n  }\n}\n```\n\nUntil [PR #5652](https://github.com/cli/cli/pull/5652) or some other solution is merged, you can use this extension\nwithout having to install additional system utilities like `jq` which may not be available for your platform or\notherwise difficult to obtain e.g., requiring a bunch of prerequisites.\n\n### Formatting\n\nLike several `gh` commands, you can pass `--template` (or `-t`) and a [Go template](https://pkg.go.dev/text/template)\nusing most functions described in `gh help formatting` - specifically, those defined [in source](https://github.com/cli/go-gh/blob/ee75bbcac35dc7d72f0a39d52e74ded343d17810/pkg/template/template.go#L58).\nOutput is always written to standard output.\n\n### Teeing\n\nIf you would like to write formatted output e.g., colorful, indented JSON, or formatted using a `--template` but save\ncompressed JSON to a file for further processing by other tools, you can pass `--tee` and a file path.\n\n```bash\ngh api graphql --paginate -f query='\n    query($endCursor: String) {\n      viewer {\n        repositories(first: 100, after: $endCursor) {\n          nodes { nameWithOwner }\n          pageInfo {\n            hasNextPage\n            endCursor\n          }\n        }\n      }\n    }\n  ' | gh merge-json --tee repos.json --template '{{range .data.viewer.repositories.nodes}}{{.nameWithOwner}}{{\"\\n\"}}{{end}}'\n```\n\n## License\n\nLicensed under the [MIT](LICENSE.txt) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaths%2Fgh-merge-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheaths%2Fgh-merge-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheaths%2Fgh-merge-json/lists"}