let points = JSON.parse(fs.readFileSync('./point.json', 'utf8')); var prefix = "!"; let userData = points[message.author.id]; if(command === "buyLevel") { if(userData.points >= 100){ userData.points -= 100; userData.level++; message.reply(`ты получил новый уровень, у тебя осталось ${userData.points} монет-а.`); fs.writeFile("./point.json", JSON.stringify(points), (err) => { if (err) console.error(err) }); } else { message.reply("У тебя не достаточно так называемых денежных средств"); } 

after adding a level, 1-2 brackets are added to the end of the .json}} how to prevent this from happening? json looks like this:

 {"198892931224961024":{"points":4,"level":10},"256434786875211778":{"points":44,"level":1}} 
  • one
    Why do you think that they are superfluous? Show how it should be yours? - vp_arth
  • @vp_arth I suspect that the vehicle is going to write data there - Igor
  • Because the console gives the error {"points": 12, "level": 0}, "287259453060022273": {"points": 16, "level": 0}}} ^ SyntaxError: Unexpected token} in JSON at position 362 - DNRAWW
  • The JSON string that is in question is valid, except for a missing colon. - Igor
  • @igor, so it looks like before adding a level - DNRAWW

1 answer 1

This was due to the Nodemon.