const fs = require('fs');
const data = {
id: 12345,
name: 'John Smith',
};
const jsonData = JSON.stringify(data, null, 4);
fs.writeFile('data.json', jsonData, (err) => {
if (err) {
console.error('Error writing file:', err);
} else {
console.log('Writing JSON to file was successful.');
}
});