📜  js 写入 json 文件 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:51.393000             🧑  作者: Mango

代码示例4
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));