Go Fast Posted March 11, 2018 Report Share 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 Link to comment Share on other sites More sharing options...
Dr. McKay Posted March 11, 2018 Report Share 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 Link to comment Share on other sites More sharing options...
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.