JS escribe en el archivo JSON
fs.writeFile ("file.json", JSON.stringify(data), function(err) {
if (err) throw err;
console.log('complete');
}
);
Fusinato
fs.writeFile ("file.json", JSON.stringify(data), function(err) {
if (err) throw err;
console.log('complete');
}
);
const fs = require('fs');
const path = require('path');
let student = {
name: 'Mike',
age: 23,
gender: 'Male',
department: 'English',
car: 'Honda'
};
fs.writeFileSync(path.resolve(__dirname, 'student.json'), JSON.stringify(student));
var fs = require('fs');
var data = {}
data.table = []
for (i=0; i <26 ; i++){
var obj = {
id: i,
square: i * i
}
data.table.push(obj)
}
fs.writeFile ("input.json", JSON.stringify(data), function(err) {
if (err) throw err;
console.log('complete');
}
);