{"id":13563091,"url":"https://github.com/koajs/json","last_synced_at":"2025-04-13T00:42:13.788Z","repository":{"id":13732901,"uuid":"16427212","full_name":"koajs/json","owner":"koajs","description":"pretty-printed JSON response middleware","archived":false,"fork":false,"pushed_at":"2023-05-30T12:56:39.000Z","size":30,"stargazers_count":199,"open_issues_count":3,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T00:42:06.185Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/koajs.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","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}},"created_at":"2014-02-01T02:55:44.000Z","updated_at":"2025-01-11T00:16:02.000Z","dependencies_parsed_at":"2023-09-26T20:56:56.021Z","dependency_job_id":null,"html_url":"https://github.com/koajs/json","commit_stats":{"total_commits":38,"total_committers":8,"mean_commits":4.75,"dds":0.6578947368421053,"last_synced_commit":"af9158051063561e63d3dcced8f3cf73894578aa"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Fjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Fjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Fjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koajs%2Fjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koajs","download_url":"https://codeload.github.com/koajs/json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650417,"owners_count":21139672,"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":[],"created_at":"2024-08-01T13:01:15.092Z","updated_at":"2025-04-13T00:42:13.767Z","avatar_url":"https://github.com/koajs.png","language":"JavaScript","readme":"# koa-json\n\nJSON pretty-printed response middleware. Also converts node object streams to binary.\n\n## Installation\n\n```\n$ npm install koa-json\n```\n\n## Options\n\n- `pretty` default to pretty response [true]\n- `param` optional query-string param for pretty responses [none]\n- `spaces` JSON spaces [2]\n\n## Example\n\nAlways pretty by default:\n\n```js\nconst json = require('koa-json')\nconst Koa = require('koa')\nconst app = new Koa()\n\napp.use(json())\n\napp.use((ctx) =\u003e {\n  ctx.body = { foo: 'bar' }\n})\n\n// @request: GET /\n//\n// @response:\n// {\n//   \"foo\": \"bar\"\n// }\n```\n\nDefault to being disabled (useful in production), but togglable via the query-string parameter:\n\n```js\nconst Koa = require('koa')\nconst app = new Koa()\n\napp.use(json({ pretty: false, param: 'pretty' }))\n\napp.use((ctx) =\u003e {\n  ctx.body = { foo: 'bar' }\n})\n\n// @request: GET /\n//\n// @response:\n// {\"foo\":\"bar\"}\n\n// @request: GET /?pretty\n//\n// @response:\n// {\n//   \"foo\": \"bar\"\n// }\n```\n \n# License \n \n[MIT](LICENSE)\n","funding_links":[],"categories":["JavaScript","Middleware","仓库","Node.js, koa"],"sub_categories":["中间件","Utilites"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoajs%2Fjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoajs%2Fjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoajs%2Fjson/lists"}