Loading ...
Sorry, an error occurred while loading the content.

JSON.stringify in Safari

Expand Messages
  • christopher.stumm
    when testing the JSON.stringify function, i noticed that it does not seem to behave correctly in safari. The issue is with Objects. It seems to arise from the
    Message 1 of 1 , Apr 16, 2006
    • 0 Attachment
      when testing the JSON.stringify function, i noticed that it does not seem to behave
      correctly in safari. The issue is with Objects. It seems to arise from the fact that
      hasOwnProperty does not exist. It means that most Objects will be returned as null.

      I've found a "work around" (not my code), although it has some undesired side effects:

      if(!Object.hasOwnProperty){
      Object.prototype.hasOwnProperty = function(it) {
      return (this[it] && !this.constructor.prototype[it]);
      }
      }

      I was wondering if anyone else encountered this problem in safari (pre safari 2.0), and if
      anyone knew of a work around that didn't have many (if any) side effects.

      Thanks.

      -Christopher
    Your message has been successfully submitted and would be delivered to recipients shortly.