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

545Re: [json] json.js breaks for-in loops

Expand Messages
  • Martin Cooper
    Oct 14, 2006
      On 10/14/06, Scott Chapman <scott_list@...> wrote:
      >
      > It's easy to modify json.js so it doesn't extend Object.prototype. That
      > was a
      > bad design in my opinion.


      It's not just exceptionally bad design, it's chronically inconsiderate
      programming. Nobody could use that code inside portlets, because they'd risk
      breaking any and all other JavaScript on the same portal page over which
      they have no control. Even outside a portal environment, it's going to break
      other libraries that developers might already be using, not to mention their
      own code.

      --
      Martin Cooper


      The version I use is attached.
      >
      > Scott
      >
      > Peter Michaux wrote:
      > > Hi,
      > >
      > > By extending the Object.prototype with the new property toJSONString I
      > > can no longer use for-in loops in my JavaScript.
      > >
      > > Has someone released a version of JSON that doesn't do this?
      > >
      > > Is it just as simple as changing these
      > >
      > > Object.prototype.toJSONString = function () {
      > > Array.prototype.toJSONString = function () {
      > > String.prototype.parseJSON = function () {
      > >
      > > to something like
      > >
      > > JSON.objectToJSONString = function () {
      > > JSON.arrayToJSONString = function () {
      > > JSON.parseJSON = function () {
      > >
      > > or are their other catches that I have missed?
      > >
      > > Thank you,
      > > Peter
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Show all 10 messages in this topic