{"id":15821181,"url":"https://github.com/fdawgs/fastify-json-to-xml","last_synced_at":"2025-05-12T13:26:15.930Z","repository":{"id":65718270,"uuid":"597017381","full_name":"Fdawgs/fastify-json-to-xml","owner":"Fdawgs","description":"Fastify plugin to serialise JSON responses into XML","archived":false,"fork":false,"pushed_at":"2025-05-11T19:25:18.000Z","size":246,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-11T20:25:31.186Z","etag":null,"topics":["fastify","json","nodejs","plugin","serialise","serialize","xml"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/fastify-json-to-xml","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/Fdawgs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"Fdawgs"}},"created_at":"2023-02-03T12:51:31.000Z","updated_at":"2025-05-11T19:25:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc56331e-147a-4b49-9566-5567493509b4","html_url":"https://github.com/Fdawgs/fastify-json-to-xml","commit_stats":{"total_commits":167,"total_committers":4,"mean_commits":41.75,"dds":0.2694610778443114,"last_synced_commit":"958f1112e2748acd52816446ea0927067bd597fc"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-json-to-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-json-to-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-json-to-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-json-to-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fdawgs","download_url":"https://codeload.github.com/Fdawgs/fastify-json-to-xml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253746653,"owners_count":21957608,"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":["fastify","json","nodejs","plugin","serialise","serialize","xml"],"created_at":"2024-10-05T07:20:49.286Z","updated_at":"2025-05-12T13:26:15.925Z","avatar_url":"https://github.com/Fdawgs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/Fdawgs"],"categories":[],"sub_categories":[],"readme":"# fastify-json-to-xml\n\n[![GitHub release](https://img.shields.io/github/release/Fdawgs/fastify-json-to-xml.svg)](https://github.com/Fdawgs/fastify-json-to-xml/releases/latest/)\n[![npm version](https://img.shields.io/npm/v/fastify-json-to-xml)](https://npmjs.com/package/fastify-json-to-xml)\n[![CI](https://github.com/Fdawgs/fastify-json-to-xml/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Fdawgs/fastify-json-to-xml/actions/workflows/ci.yml)\n[![Coverage status](https://coveralls.io/repos/github/Fdawgs/fastify-json-to-xml/badge.svg?branch=main)](https://coveralls.io/github/Fdawgs/fastify-json-to-xml?branch=main)\n[![code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat)](https://github.com/prettier/prettier)\n\n\u003e Fastify plugin to serialise JSON responses into XML\n\n## Overview\n\nThe `fastify-json-to-xml` plugin adds an `onSend` hook that supports serialising 'application/json' responses into XML if:\n\n- The `Accept` HTTP request header only includes 'application/xml'\n- The `Accept` HTTP request header explicitly includes the 'application/xml' media type before 'application/json'\n\n## Installation\n\nInstall using `npm`:\n\n```bash\nnpm i fastify-json-to-xml\n```\n\nFor Fastify v4.x support, use `fastify-json-to-xml@1.1.12`.\n\n## Example usage\n\n```js\nconst Fastify = require(\"fastify\");\nconst jsonToXml = require(\"fastify-json-to-xml\");\n\nconst server = Fastify();\nserver.register(jsonToXml);\n\nserver.get(\"/\", (_req, res) =\u003e {\n\tres.send({ example: \"I'm an example value!\" });\n});\n\nserver.listen(3000, (err) =\u003e {\n\tif (err) throw err;\n\tconsole.log(\"Server listening on 3000\");\n});\n```\n\nMake an HTTP GET request to the route above, with application/xml in the `accept` HTTP request header, and the results will look like so:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\u003cresponse\u003e\u003cexample\u003eI'm an example value!\u003c/example\u003e\u003c/response\u003e\n```\n\n## Replacing invalid XML characters in output\n\nBy default, this plugin will throw an error if the JSON response it is transforming has characters that XML considers invalid, such as \"$\".\nSet `replaceInvalidChars: true` in the plugin options and they will be replaced with the Unicode replacement character (U+FFFD) instead, and the plugin will not throw an error.\n\nFor example:\n\n```json\n{ \"$test-key\": \"test-value\" }\n```\n\nWill become:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\u003cresponse\u003e\u003c�test-key\u003etest-value\u003c/�test-key\u003e\u003c/response\u003e'\n```\n\n## Contributing\n\nContributions are welcome, and any help is greatly appreciated!\n\nSee [the contributing guide](https://github.com/Fdawgs/.github/blob/main/CONTRIBUTING.md) for details on how to get started.\nPlease adhere to this project's [Code of Conduct](https://github.com/Fdawgs/.github/blob/main/CODE_OF_CONDUCT.md) when contributing.\n\n## Acknowledgements\n\n- [**Aras Abbasi**](https://github.com/uzlopak) - TypeScript support\n\n## License\n\n`fastify-json-to-xml` is licensed under the [MIT](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdawgs%2Ffastify-json-to-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdawgs%2Ffastify-json-to-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdawgs%2Ffastify-json-to-xml/lists"}