{"id":13454403,"url":"https://github.com/sindresorhus/write-json-file","last_synced_at":"2025-05-15T17:07:30.007Z","repository":{"id":55410053,"uuid":"41783992","full_name":"sindresorhus/write-json-file","owner":"sindresorhus","description":"Stringify and write JSON to a file atomically","archived":false,"fork":false,"pushed_at":"2024-07-26T11:25:37.000Z","size":45,"stargazers_count":222,"open_issues_count":2,"forks_count":40,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-07T17:21:53.026Z","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/sindresorhus.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":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2015-09-02T06:26:04.000Z","updated_at":"2025-04-11T07:52:59.000Z","dependencies_parsed_at":"2024-11-14T07:40:07.163Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/write-json-file","commit_stats":{"total_commits":65,"total_committers":10,"mean_commits":6.5,"dds":"0.23076923076923073","last_synced_commit":"301b0780592893953a6b6566e3ec92bca342def1"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fwrite-json-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fwrite-json-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fwrite-json-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fwrite-json-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/write-json-file/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"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-07-31T08:00:53.782Z","updated_at":"2025-05-15T17:07:29.954Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# write-json-file\n\n\u003e Stringify and write JSON to a file [atomically](https://github.com/npm/write-file-atomic)\n\nCreates directories for you as needed.\n\n## Install\n\n```sh\nnpm install write-json-file\n```\n\n## Usage\n\n```js\nimport {writeJsonFile} from 'write-json-file';\n\nawait writeJsonFile('foo.json', {foo: true});\n```\n\n## API\n\n### writeJsonFile(filePath, data, options?)\n\nReturns a `Promise`.\n\n### writeJsonFileSync(filePath, data, options?)\n\n#### options\n\nType: `object`\n\n##### indent\n\nType: `string | number | undefined`\\\nDefault: `'\\t'`\n\nIndentation as a string or number of spaces.\n\nPass in `undefined` for no formatting.\n\nIf you set both this and `detectIndent`, this value will be used when the indentation cannot be detected.\n\n##### detectIndent\n\nType: `boolean`\\\nDefault: `false`\n\nDetect indentation automatically if the file exists.\n\n##### sortKeys\n\nType: `boolean | Function`\\\nDefault: `false`\n\nSort the keys recursively.\n\nOptionally pass in a [`compare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) function.\n\n##### replacer\n\nType: `Function`\n\nPassed into [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter).\n\n##### mode\n\nType: `number`\\\nDefault: `0o666`\n\nThe [mode](https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation) used when writing the file.\n\n## Related\n\n- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file\n- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","Repository","包","目录","Uncategorized","JavaScript","Filesystem"],"sub_categories":["Filesystem","Object / JSON / JSON Schema","文件系统","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fwrite-json-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fwrite-json-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fwrite-json-file/lists"}