【发布时间】:2022-01-14 00:05:24
【问题描述】:
let AccountDetails = {
dformat,
username,
password,
accountType,
charity
};
AccountDetails.dformat
let creds = JSON.stringify(AccountDetails);
fs.appendFile("LoginID\\JsonCreds.json",creds,(err) => {
if (err) {
console.log(err);
}
else {
// Get the file contents after the append operation
console.log("\nFile Contents of file after append:",
fs.readFileSync("LoginID\\JsonCreds.json", "utf8"));
}
});
Output:-{
"dformat": "2021-12-09 10:09:53","username": "An191428","password": "Root@123","accountType": "Basic Enterprise Postpaid","charity": "Non-charity"
}
我希望输出如下:-2021-12-09 10:09:53|An191428|Root@123|Basic Enterprise Postpaid|Non-charity 像这样并且每次追加后还想要新行,请帮助我。
【问题讨论】:
标签: node.js json testing automation fs