Here is a JSON object I have:
[#1={id:"2012-05-04", title:"Scheduled", start:(new Date(1336096800000)), source:{events:[#1#], className:[]}, _id:"2012-05-04", _start:(new Date(1336089600000)), end:null, _end:null, allDay:true, className:[]}]
I attempted to stringify it as follows:
var test = JSON.stringify(resourceVacation, censor(resourceVacation));
function censor(censor) {
return (function() {
var i = 0;
return function(key, value) {
if (i !== 0 && typeof(censor) === 'object' && typeof(value) == 'object' && censor == value)
return '[Circular]';
++i; // so we know we aren't using the original object anymore
return value;
}
})(censor);
}
I used censor based on this information :Chrome sendrequest error: TypeError: Converting circular structure to JSONn
However, I encountered the following browser exception:
Uncaught TypeError: Converting circular structure to JSON
Here is the JavaScript object:
The previous JSON object was obtained using toSource() at Mozilla browser. Any suggestions on how to resolve this issue !!
============================UPDATE========================
Let me provide you with the scenario from the beginning: 1 -Initially: I have a form and at the end I construct a JavaScript object which looks like:
#1=[{id:"2012-05-03", title:"Scheduled", start:(new Date(1336010400000)), source:{events:#1#, className:[]}, _id:"2012-05-03", _start:(new Date(1336003200000)), end:null, _end:null, allDay:true, className:[]}]
This object can be stringified without any issues ... KEEP IN MIND THAT IT IS similar to the one causing an exception later.
2- Later on, I remove objects from this array using :
function deleteVacation(day) {
for (var index = 0; index < resourceVacation.length; index++) {
if (resourceVacation[index].id == day)
resourceVacation.splice(index,1);
}
3-When I attempt to stringify that array after deleting a single object, I encounter the mentioned exception. So .. any thoughts on why it worked the first time but failed the second time !!