Go Fast Posted March 11, 2018 Report Posted March 11, 2018 My Json file looks like this:{"TotalItemsTraded": {"TotalKeys": 0} } Json is called: 'TotalSold.json' How can I update it's value? I'm trying to add an integer to 'TotalKeys' (Another function is calculating everything and im just trying to update the json file value) Quote
Dr. McKay Posted March 11, 2018 Report Posted March 11, 2018 let sold = JSON.parse(require('fs').readFileSync('TotalSold.json').toString('utf8')); sold.TotalItemsTraded.TotalKeys += something; require('fs').writeFileSync('TotalSold.json', JSON.stringify(sold, undefined, "\t")); Go Fast 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.