I am trying to either update or remove (and then rewrite) a JSON key in node.js
JSON:
{"users":[{"Discordid":"discid","Username":"user","Password":"pass","School":"schoolname"}, {"Discordid":"discid1","Username":"user1","Password":"pass1","School":"schoolname1"}]}
I want to remove the entire {"Discordid":"discid","Username":"user","Password":"pass","School":"schoolname"}
via a for loop so I make use of variable a which equals the number in which the data is I want to delete.
I have tried:
fs.readFile('databases/magistercredentials.json', 'utf-8', function (err, data1) {
if (err) throw err
var magistercreds = JSON.parse(data1)
for (a = 0; a < Object.keys(magistercreds.users).length; a++) delete magistercreds.users[a]
And other things which all did not work.