https://github.com/niftinessafoot/write-json
📝 A JSON file-writing package designed for NPM initializers and places where Node needs to write static files.
https://github.com/niftinessafoot/write-json
filesystem json node
Last synced: 5 months ago
JSON representation
📝 A JSON file-writing package designed for NPM initializers and places where Node needs to write static files.
- Host: GitHub
- URL: https://github.com/niftinessafoot/write-json
- Owner: niftinessafoot
- License: mit
- Created: 2024-04-01T21:03:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-23T23:44:34.000Z (almost 2 years ago)
- Last Synced: 2025-09-05T18:45:21.674Z (10 months ago)
- Topics: filesystem, json, node
- Language: JavaScript
- Homepage:
- Size: 146 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# write-json
A JSON file-writing package designed for NPM initializers and places where Node needs to write static files.
## installation
install: `npm i --D @afoot/write-json`
import: `import writeJson from '@afoot/write-json'`
## documentation
write-json takes the following params:
- **filename** | `string` name and extension of the file to be written
- **json** | `Object` any valid JSON statement. Ideally object literals or arrays
- **config** | `Object` configuration object (see below)
### config object breakdown
```js
{
errorCallback: null, // Calls if file write fails
willFormat: true, // Option to disable tab formatting
root: `(current working directory)`, // File path to write
writeOptions: {flag:'w'} // Node options object for `writeFile`
}
```
## example
```js
const obj = { name: 'test', version: '0.0.1' };
const filename = 'package.json';
writeJson(filename, obj);
```
## license
[MIT](./LICENSE) © [Matthew Smith](http://www.niftinessafoot.com)
## made with ❤️ and ☕️ by
 [Matthew Smith](https://github.com/niftinessafoot)