My project makes use of JSON to store user data, but I am having a strange issue with it. One of my methods is a delete method that is supposed to delete saved data and replace it with a single entry indicating no saved data in that slot.
public void deleteSave(int id) {
// Delete the save with the given ID.
allSaves.setJSONObject(id - 1, emptySave);
writeSave(); // Calls a function that executes a "saveJSONArray()"
System.out.println(emptySave);
}
The issue that I am having is that somehow, the emtpySave JSONObject gets changed to have the contents of what was just erased stored in it even though I never requested such a change to occur. This results in future deletions not working since the data that is now stored in it it just being written in place. Does anyone have any idea what is going on? I am using Processing 2.2.1.