You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
617 B
23 lines
617 B
2 years ago
|
# outputJsonSync(file, object, [options])
|
||
|
|
||
|
Almost the same as [`writeJsonSync`](writeJson-sync.md), except that if the directory does not exist, it's created.
|
||
|
`options` are what you'd pass to [`jsonFile.writeFileSync()`](https://github.com/jprichardson/node-jsonfile#writefilesyncfilename-obj-options).
|
||
|
|
||
|
**Alias:** `outputJSONSync()`
|
||
|
|
||
|
- `file` `<String>`
|
||
|
- `object` `<Object>`
|
||
|
- `options` `<Object>`
|
||
|
|
||
|
## Example:
|
||
|
|
||
|
```js
|
||
|
const fs = require('fs-extra')
|
||
|
|
||
|
const file = '/tmp/this/path/does/not/exist/file.json'
|
||
|
fs.outputJsonSync(file, {name: 'JP'})
|
||
|
|
||
|
const data = fs.readJsonSync(file)
|
||
|
console.log(data.name) // => JP
|
||
|
```
|