{"id":13454673,"url":"https://github.com/sindresorhus/strip-json-comments","last_synced_at":"2025-05-14T10:09:43.030Z","repository":{"id":11904730,"uuid":"14468669","full_name":"sindresorhus/strip-json-comments","owner":"sindresorhus","description":"Strip comments from JSON. Lets you use comments in your JSON files!","archived":false,"fork":false,"pushed_at":"2023-07-04T11:22:45.000Z","size":149,"stargazers_count":603,"open_issues_count":1,"forks_count":53,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-04-09T18:09:41.272Z","etag":null,"topics":["json","json-comments","jsonc","npm-package"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"pickerel/owl","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2013-11-17T15:04:17.000Z","updated_at":"2025-04-02T08:18:43.000Z","dependencies_parsed_at":"2023-09-24T06:32:43.631Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/strip-json-comments","commit_stats":{"total_commits":69,"total_committers":21,"mean_commits":"3.2857142857142856","dds":"0.30434782608695654","last_synced_commit":"85611bf8a07246bca27f949c997a1460c57bbe9f"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-json-comments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-json-comments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-json-comments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fstrip-json-comments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/strip-json-comments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248305839,"owners_count":21081574,"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":["json","json-comments","jsonc","npm-package"],"created_at":"2024-07-31T08:00:56.688Z","updated_at":"2025-04-11T03:33:57.745Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","Repository","json","包","Parsing","目录","JavaScript","Number"],"sub_categories":["Parsing","Object / JSON / JSON Schema","解析","解析工具"],"readme":"# strip-json-comments\n\n\u003e Strip comments from JSON. Lets you use comments in your JSON files!\n\nThis is now possible:\n\n```js\n{\n\t// Rainbows\n\t\"unicorn\": /* ❤ */ \"cake\"\n}\n```\n\nIt will replace single-line comments `//` and multi-line comments `/**/` with whitespace. This allows JSON error positions to remain as close as possible to the original source.\n\nAlso available as a [Gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[Grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[Broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin.\n\n## Install\n\n```sh\nnpm install strip-json-comments\n```\n\n## Usage\n\n```js\nimport stripJsonComments from 'strip-json-comments';\n\nconst json = `{\n\t// Rainbows\n\t\"unicorn\": /* ❤ */ \"cake\"\n}`;\n\nJSON.parse(stripJsonComments(json));\n//=\u003e {unicorn: 'cake'}\n```\n\n## API\n\n### stripJsonComments(jsonString, options?)\n\n#### jsonString\n\nType: `string`\n\nAccepts a string with JSON and returns a string without comments.\n\n#### options\n\nType: `object`\n\n##### trailingCommas\n\nType: `boolean`\\\nDefault: `false`\n\nStrip trailing commas in addition to comments.\n\n##### whitespace\n\nType: `boolean`\\\nDefault: `true`\n\nReplace comments and trailing commas with whitespace instead of stripping them entirely.\n\n## Benchmark\n\n```sh\nnpm run bench\n```\n\n## Related\n\n- [strip-json-comments-cli](https://github.com/sindresorhus/strip-json-comments-cli) - CLI for this module\n- [strip-css-comments](https://github.com/sindresorhus/strip-css-comments) - Strip comments from CSS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fstrip-json-comments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fstrip-json-comments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fstrip-json-comments/lists"}