title: Javascript JSON.stringify function is not working
body: <p>I have tried to convert a JS object into JSON.</p>
  
  <pre><code>JSON.stringify({a:1, toJSON: function(){}})
  </code></pre>
  
  <p>Native JSON stringify is not working as expected. JSON stringify executes toJSON function in JS object internally. I have overwritten native code as follows,</p>
  
  <pre><code>// Adding try catch for non JSON support browsers.
  try{
   _jsonStringify = JSON.stringify;
   JSON.stringify = function(object){
      var fnCopy = object.toJSON; 
      object.toJSON = undefined;
      var result =  _jsonStringify(object);
      object.toJSON = fnCopy;
      return result;      
   };
  }catch(e){}
  </code></pre>
  
  <p>It is working fine. is there any other better way to do this?. is there any specific reason in native code execute <strong>toJSON</strong> function in input object?</p>