website/node_modules/fs-extra/docs/outputJson-sync.md

outputJsonSync(file, object, [options])

Almost the same as writeJsonSync, except that if the directory does not exist, it's created.

Alias: outputJSONSync()

Example:

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


JohnCoene/chirp documentation built on May 25, 2021, 6:33 p.m.