{"id":15821281,"url":"https://github.com/eomm/fastify-json5","last_synced_at":"2025-05-12T13:14:55.290Z","repository":{"id":61637378,"uuid":"551303946","full_name":"Eomm/fastify-json5","owner":"Eomm","description":"This plugin enable your server to process JSON5 payloads","archived":false,"fork":false,"pushed_at":"2025-05-05T18:31:43.000Z","size":16,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T13:14:43.908Z","etag":null,"topics":["application-json5","fastify","fastify-plugin","json5"],"latest_commit_sha":null,"homepage":"","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/Eomm.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":"2022-10-14T06:48:30.000Z","updated_at":"2025-05-05T18:31:40.000Z","dependencies_parsed_at":"2024-10-26T12:47:24.614Z","dependency_job_id":"f170f513-3ae4-42b0-82af-4c38d80af315","html_url":"https://github.com/Eomm/fastify-json5","commit_stats":{"total_commits":7,"total_committers":2,"mean_commits":3.5,"dds":0.4285714285714286,"last_synced_commit":"6ccaf549f8876ceef0401ed1102fc158c0f3d845"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-json5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-json5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-json5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eomm%2Ffastify-json5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eomm","download_url":"https://codeload.github.com/Eomm/fastify-json5/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745196,"owners_count":21957319,"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":["application-json5","fastify","fastify-plugin","json5"],"created_at":"2024-10-05T07:21:26.679Z","updated_at":"2025-05-12T13:14:55.262Z","avatar_url":"https://github.com/Eomm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-json5\n\n[![ci](https://github.com/Eomm/fastify-json5/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Eomm/fastify-json5/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/fastify-json5)](https://www.npmjs.com/package/fastify-json5)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\nThis plugin enable your server to process JSON5 payloads.  \nIt adds a new `application/json5` content type parser to Fastify and\ndecorate the `reply` object with a `sendJSON5()` utility.\n\n\n## Install\n\n```\nnpm install fastify-json5\n```\n\n### Compatibility\n\n| Plugin version | Fastify version |\n| -------------- |:---------------:|\n| `^2.0.0` | `^5.0.0` |\n| `^1.0.0` | `^4.0.0` |\n\n\n## Usage\n\n\n```js\nconst fastify = require('fastify')\nconst fastifyJson5 = require('fastify-json5')\n\nconst app = fastify()\napp.register(fastifyJson5, { \n  reviver: (key, value) =\u003e value // optionally pass a reviver function\n})\n\napp.post('/', (req, reply) =\u003e {\n  console.log(req.body)\n  reply.sendJSON5(req.body, {\n    replacer, // optionally\n    space,    // optionally\n    quote     // optionally\n  })\n})\n\napp.inject({\n  method: 'POST',\n  url: '/',\n  headers: { 'content-type': 'application/json5' },\n  payload: `{\n    // comments\n    unquoted: 'and you can quote me on that',\n    singleQuotes: 'I can use \"double quotes\" here',\n    lineBreaks: \"Look, Mom! \\\n  No \\\\n's!\",\n    hexadecimal: 0xdecaf,\n    leadingDecimalPoint: .8675309, andTrailing: 8675309.,\n    positiveSign: +1,\n    negativeSign: -9,\n    trailingComma: 'in objects', andIn: ['arrays',],\n    \"backwardsCompatible\": \"with JSON\",\n  }`\n})\n```\n\n\n## Options\n\nThis plugin uses the [`json5`](https://github.com/json5/json5) under the hood.\nSo you can provide the same options of the `json5` module.\n\nWhen you register the plugin you can pass the [`JSON.parse`](https://github.com/json5/json5#parameters) options:\n\n- `reviver`\n\nWhen you call the `reply.sendJSON5()` you can pass the [`JSON.stringify`](https://github.com/json5/json5#parameters-1):\n\n- `replacer`\n- `space`\n- `quote`\n\n\n## Security\n\nBy default, the `json5` module behaves like the `JSON.parse` and `JSON.stringify` methods.\nSo [it parse and add to the prototype](https://github.com/json5/json5/commit/4a8c4568fe6bf85daf6f473aaa50007c43f74d6e) the `__proto__` property.\n\nThis module implements a security check to avoid the `__proto__` property to be added to the prototype. In this case the plugin will throw an http 400 error.\n\n\n## License\n\nCopyright [Manuel Spigolon](https://github.com/Eomm), Licensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feomm%2Ffastify-json5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feomm%2Ffastify-json5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feomm%2Ffastify-json5/lists"}