【发布时间】:2017-10-17 12:40:25
【问题描述】:
我有这个config.json 文件:
{
"account_name": {
"min_len": "3",
"max_len": "15",
"upperCase": true,
"lowerCase": true,
"numbers": true,
"specialChar": false,
"capitalize": false,
"duplication": false,
"startWithCapital": false
},
"password": {
"min_len": "6",
"max_len": "20",
"upperCase": true,
"lowerCase": true,
"numbers": true,
"specialChar": true,
"capitalize": false,
"duplication": false,
"StartWithCapital": false
}
}
如何从代码中向这个 .json 文件添加其他值? 例如:
var keysOpt = require('../config/config.json');
KeysOpt.name = "eric"
KeyPot.save() // will save the new field to the file itself
【问题讨论】:
标签: javascript json node.js file fs