{"id":37165953,"url":"https://github.com/kpsaurus/gin-json-renderer","last_synced_at":"2026-01-14T19:40:07.266Z","repository":{"id":298110448,"uuid":"913432214","full_name":"kpsaurus/gin-json-renderer","owner":"kpsaurus","description":"A custom JSON renderer for Gin framework","archived":false,"fork":false,"pushed_at":"2025-01-07T17:11:23.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T13:41:38.742Z","etag":null,"topics":["framework","gin","go","golang"],"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/kpsaurus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-01-07T17:10:08.000Z","updated_at":"2025-01-07T17:12:38.000Z","dependencies_parsed_at":"2025-06-09T13:44:20.884Z","dependency_job_id":"087106bb-ee9a-4146-ba74-7b858fac8be0","html_url":"https://github.com/kpsaurus/gin-json-renderer","commit_stats":null,"previous_names":["kpsaurus/gin-json-renderer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kpsaurus/gin-json-renderer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpsaurus%2Fgin-json-renderer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpsaurus%2Fgin-json-renderer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpsaurus%2Fgin-json-renderer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpsaurus%2Fgin-json-renderer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kpsaurus","download_url":"https://codeload.github.com/kpsaurus/gin-json-renderer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpsaurus%2Fgin-json-renderer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["framework","gin","go","golang"],"created_at":"2026-01-14T19:40:06.601Z","updated_at":"2026-01-14T19:40:07.249Z","avatar_url":"https://github.com/kpsaurus.png","language":"Go","readme":"# JSON renderer for Gin framework\n\n`ginjsonrenderer` is a custom JSON renderer for the [Gin framework](https://github.com/gin-gonic/gin). Heavily inspired by Django REST framework's JSON renderer, it provides a consistent and structured way to return JSON responses, including support for pagination, custom data, and error handling.\n\n## Features\n\n- **Standardized JSON Response Structure**: Ensure consistent API responses across your application.\n- **Pagination Support**: Easily include pagination metadata in your responses.\n- **Customizable**: Define HTTP status codes, data payloads, and error details.\n- **Seamless Integration**: Built specifically for the Gin framework.\n\n## Installation\n\nInstall the package using `go get`:\n\n```bash\ngo get github.com/yourusername/ginjsonrenderer\n```\n\n## Usage\n\n```bash\nimport \"github.com/kpsaurus/ginjsonrenderer\"\n```\n\n## Basic Usage\n\nExample: Basic JSON Response\n\nHere's a basic example of how to use ginjsonrenderer to return a JSON response:\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/kpsaurus/ginjsonrenderer\"\n)\n\nfunc main() {\n\tr := gin.Default()\n\n\tr.GET(\"/example\", func(c *gin.Context) {\n\t\tdata := gin.H{\"message\": \"Hello, World!\"}\n\t\tginjsonrenderer.JSON(c, http.StatusOK, data, nil)\n\t})\n\n\tr.Run(\":8080\")\n}\n```\n\nExample: JSON Response with Pagination\n\nYou can include pagination details in your response by passing a Pagination struct:\n\n```go\nr.GET(\"/paginated-example\", func(c *gin.Context) {\n\tpagination := \u0026ginjsonrenderer.Pagination{\n\t\tOffset: 0,\n\t\tLimit:  10,\n\t\tTotal:  2,\n\t}\n\tdata := gin.H{\"items\": []string{\"item1\", \"item2\"}}\n\tginjsonrenderer.JSON(c, http.StatusOK, data, nil, pagination)\n})\n```\n\nResponse Format\n\nThe response structure will look like this:\n\n```json\n{\n  \"status\": 200,\n  \"message\": \"OK\",\n  \"pagination\": {\n    \"offset\": 0,\n    \"limit\": 10,\n    \"total\": 2\n  },\n  \"data\": {\n    \"items\": [\"item1\", \"item2\"]\n  },\n  \"errors\": null\n}\n```\n\n## Function Reference\n\n```go\nfunc JSON(c *gin.Context, statusCode int, data interface{}, errors interface{}, pagination ...*Pagination)\n```\n\n- c: Gin's context.\n- statusCode: HTTP status code (e.g., http.StatusOK).\n- data: The data payload to include in the response.\n- errors: Error details, if any (can be nil if no errors).\n- pagination: (Optional) Pagination metadata.\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests for improvements or bug fixes.\n\n## License\n\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpsaurus%2Fgin-json-renderer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkpsaurus%2Fgin-json-renderer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpsaurus%2Fgin-json-renderer/lists"}