Potential JSONObject bug?

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()"

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.

Can you please post a complete example that we can copy and paste to see the error?

I was able to identify the issue. Apparently when I wrote the code for this section of my program, I allowed myself to forget that setting an object variable equal to another object variable does not create a copy of it, but they point to the same thing. I went back and rewrote my code to not include this oversight and it now works as it should.