Make a copy of a JS object that will not throw when JSON.stringified