Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536
  1. # writeJson(file, object, [options, callback])
  2. Writes an object to a JSON file. `options` are the same that
  3. you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
  4. **Alias:** `writeJSON()`
  5. - `file` `<String>`
  6. - `object` `<Object>`
  7. - `options` `<Object>`
  8. - `callback` `<Function>`
  9. ## Example:
  10. ```js
  11. const fs = require('fs-extra')
  12. fs.writeJson('./package.json', {name: 'fs-extra'}, err => {
  13. if (err) return console.error(err)
  14. console.log('success!')
  15. })
  16. // With Promises
  17. fs.writeJson('./package.json', {name: 'fs-extra'})
  18. .then(() => {
  19. console.log('success!')
  20. })
  21. .catch(err => {
  22. console.error(err)
  23. })
  24. ```
  25. ---
  26. **See also:** [`outputJson()`](outputJson.md)