Needs to prefer the version from Prototype if one is available.

Otherwise JSON.stringify([]) would become "\"[]\"".

See http://stackoverflow.com/questions/710586/json-stringify-bizarreness

Quoting:

  The function JSON.stringify() defined in ECMAScript 5 and above (Page 201 -
  the JSON Object, pseudo-code Page 205), uses the function toJSON() when
  available on objects.

  Because Prototype.js (or another library that you are using) defines an
  Array.prototype.toJSON() function, arrays are first converted to strings
  using Array.prototype.toJSON() then string quoted by JSON.stringify(),
  hence the incorrect extra quotes around the arrays.