title: JavaScript exception :Uncaught TypeError: Converting circular structure to JSON
body: <p>I hava JSON object :</p>
  
  <pre><code>[#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:[]}]
  </code></pre>
  
  <p>I try to stringify it :</p>
  
  <pre><code>var test = JSON.stringify(resourceVacation, censor(resourceVacation));
  
  function censor(censor) {
      return (function() {
          var i = 0;
          return function(key, value) {
              if (i !== 0 &amp;&amp; typeof(censor) === 'object' &amp;&amp; typeof(value) == 'object' &amp;&amp; censor == value)
                  return '[Circular]';
  
              ++i; // so we know we aren't using the original object anymore
  
              return value;
          }
      })(censor);
  }
  </code></pre>
  
  <p>I use censor as mentioned here :<a href="https://stackoverflow.com/questions/4816099/chrome-sendrequest-error-typeerror-converting-circular-structure-to-jso">Chrome sendrequest error: TypeError: Converting circular structure to JSON</a>n</p>
  
  <p>However I get the following exception over the browser:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Converting circular structure to JSON</p>
  </blockquote>
  
  <p>Here is the Java Script object:
  <img src="https://i.stack.imgur.com/5NfuY.jpg" alt="enter image description here"></p>
  
  <p>I got the previous JSON object using toSource() at Mozilla browser.
  Any idea how to fix it !!</p>
  
  <p>============================UPDATE========================</p>
  
  <p>Actually I need to share with you the scnerio from the beginning:
    1 -Initially: I have a form and at the end I build java script object which is :</p>
  
  <pre><code>#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:[]}]
  </code></pre>
  
  <p><strong>This object is stringified normally ... NOTE THAT IT"S typical to the one that would fire exception later</strong>.</p>
  
  <p>2- Then later I delete objects from this array using :</p>
  
  <pre><code>function deleteVacation(day) {
      for (var index = 0; index &lt; resourceVacation.length; index++) {
          if (resourceVacation[index].id == day)
  
              resourceVacation.splice(index,1);
      }
  </code></pre>
  
  <p>3-When I try to stringify that array after I deleted a single object , I get the mentioned exception.
  So .. anu ideas why does it passed the first time and failed 2nd time !!</p>