您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

outputJson-sync.md 617 B

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. ```