{"id":22370353,"url":"https://github.com/alpheustangs/jder","last_synced_at":"2025-03-26T16:41:25.227Z","repository":{"id":261675264,"uuid":"867485097","full_name":"alpheustangs/jder","owner":"alpheustangs","description":"A standardized structure for JSON responses","archived":false,"fork":false,"pushed_at":"2024-11-07T20:14:59.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T21:09:23.339Z","etag":null,"topics":["api","data","error","json","response","specification","structure"],"latest_commit_sha":null,"homepage":"","language":"Markdown","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/alpheustangs.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}},"created_at":"2024-10-04T06:47:02.000Z","updated_at":"2024-11-07T20:15:03.000Z","dependencies_parsed_at":"2024-11-07T20:40:01.146Z","dependency_job_id":null,"html_url":"https://github.com/alpheustangs/jder","commit_stats":null,"previous_names":["alpheustangs/jder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fjder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fjder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fjder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alpheustangs%2Fjder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alpheustangs","download_url":"https://codeload.github.com/alpheustangs/jder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245696906,"owners_count":20657800,"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":["api","data","error","json","response","specification","structure"],"created_at":"2024-12-04T19:44:58.762Z","updated_at":"2025-03-26T16:41:25.193Z","avatar_url":"https://github.com/alpheustangs.png","language":"Markdown","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Data Error Response (JDER)\n\nThe JSON Data Error Response (JDER) specification defines a standardized structure for JSON responses that can be used for both success and failure scenarios.\n\n## Structure\n\nThe following is the structure of the response.\n\n### Root Strucutre\n\nThe root structure is a JSON object with the following fields:\n\n| Field     | Type    | Description                                      |\n| --------- | ------- | ------------------------------------------------ |\n| `success` | Boolean | Indicates whether the response is success or not |\n| `data`    | Object  | Contains the data payload                        |\n| `error`   | Object  | Contains the error details                       |\n\n### `success` Field\n\nThe `success` field indicates whether the response is successful. However, it can be omitted if the HTTP status code is already used to convey this information, as shown in the examples below:\n\nSuccess response (HTTP Status: `200`):\n\n```json\n{\n    \"data\": {\n        \"message\": \"Hello, World!\"\n    }\n}\n```\n\nFailure response (HTTP Status: `404`):\n\n```json\n{\n    \"error\": {\n        \"code\": \"not_found\"\n    }\n}\n```\n\n### `data` Field\n\nThe `data` field contains the response payload when `success` is `true`.\n\n### `error` Field\n\nThe `error` field provides error information when `success` is `false`.\n\n| Field     | Type   | Description                 |\n| --------- | ------ | --------------------------- |\n| `code`    | String | Error code                  |\n| `field`   | String | Field that caused the error |\n| `message` | String | Error message               |\n\nEach API should define a set of error codes for consistent error handling across clients. For example, a parsing error may use the code `parse_error`, a timeout error may use the code `timeout`, and so on.\n\n## Examples\n\nBelow are examples of both success and failure responses:\n\n### Success Response\n\nA basic success response:\n\n```json\n{\n    \"success\": true\n}\n```\n\nA success response that returns a single object in the `data` field:\n\n```json\n{\n    \"success\": true,\n    \"data\": {\n        \"message\": \"Hello, World!\"\n    }\n}\n```\n\nA success response that returns a list of items in the `data` field:\n\n```json\n{\n    \"success\": true,\n    \"data\": [\n        {\n            \"id\": 1,\n            \"name\": \"John\"\n        }, \n        {\n            \"id\": 2,\n            \"name\": \"Jane\"\n        }\n    ]\n}\n```\n\n### Failure Response\n\nA failure response with only the `code` field:\n\n```json\n{\n    \"success\": false,\n    \"error\": {\n        \"code\": \"not_found\",\n    }\n}\n```\n\nA failure response representing an internal server error:\n\n```json\n{\n    \"success\": false,\n    \"error\": {\n        \"code\": \"server_error\",\n        \"message\": \"Internal server error\",\n    }\n}\n```\n\nA failure response for a validation error, indicating a problem with a specific field:\n\n```json\n{\n    \"success\": false,\n    \"error\": {\n        \"code\": \"parse_error\",\n        \"field\": \"name\",\n        \"message\": \"Invalid JSON input\"\n    }\n}\n```\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpheustangs%2Fjder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falpheustangs%2Fjder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falpheustangs%2Fjder/lists"}