Writes an object to a file as JSON.
The type of the object to write.
The absolute path of the file to write.
The object to serialize and write.
A promise that resolves to an AsyncVoidIOResult indicating success or failure.
AsyncVoidIOResult
1.0.0
const config = { name: 'app', version: 1 };(await writeJsonFile('/config.json', config)) .inspect(() => console.log('Config saved')); Copy
const config = { name: 'app', version: 1 };(await writeJsonFile('/config.json', config)) .inspect(() => console.log('Config saved'));
Writes an object to a file as JSON.