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.

outputJson-sync.md 617 B

3 years ago
12345678910111213141516171819202122
  1. # outputJsonSync(file, object, [options])
  2. Almost the same as [`writeJsonSync`](writeJson-sync.md), except that if the directory does not exist, it's created.
  3. `options` are what you'd pass to [`jsonFile.writeFileSync()`](https://github.com/jprichardson/node-jsonfile#writefilesyncfilename-obj-options).
  4. **Alias:** `outputJSONSync()`
  5. - `file` `<String>`
  6. - `object` `<Object>`
  7. - `options` `<Object>`
  8. ## Example:
  9. ```js
  10. const fs = require('fs-extra')
  11. const file = '/tmp/this/path/does/not/exist/file.json'
  12. fs.outputJsonSync(file, {name: 'JP'})
  13. const data = fs.readJsonSync(file)
  14. console.log(data.name) // => JP
  15. ```