Answer the question
In order to leave comments, you need to log in
How to add data to JSON file so it is readable with NodeJS?
I have a JSON file with this entry (for example):
{
"user1": {
"login": "abcde",
"password": 12345
}
}
var file = JSON.parse(fs.readFileSync('./renderer/file.json', 'utf-8'))
file.user1.password = 23456
fs.writeFileSync('./renderer/file.json', JSON.stringify(file, null, 2));
{
"user1": {
"login": "abcde",
"password": 23456
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question