I'm trying to write to a file in nodejs and I've run into an issue that I haven't found any solutions to online.
economy.people[member.id] = 0
fs.writeFile("./economy.json", JSON.stringify(economy, null, 2), (err) => {
if (err) throw err;
console.log(economy)
console.log(JSON.stringify(economy, null, 2))
console.log('The file has been saved!');
})
When running this code, the following is returned:
{ government: 1000, banks: [], people: [ '517854168229216256': 0 ] }
{
"government": 1000,
"banks": [],
"people": []
}
The file has been saved!
I'm wondering why JSON.stringify() returns something different than a console.log(), and what I could do to fix this so that they are the same, and return the same value.