New JavaScript JSON library
30 October 2007Douglas Crockford has just posted a new version of his JavaScript JSON library that uses the original API with JSON.stringify and JSON.parse. It is available at http://www.JSON.org/json2.js. I am very happy to see this new library, as it does not pollute Object.prototype and Array.prototype and therefore does not force defensive enumeration by library users.
2 Responses to “New JavaScript JSON library”
October 30th, 2007 at 8:05 pm
Kris,
Thanks for posting this update - I completely missed the importance of this. This will work much better with my code - I wonder if we could convince Prototype to stop overloading the Object?
October 31st, 2007 at 12:02 pm
I have no problem with overloading Object, that doesn’t affect enumeration at all. It is only Object.prototype, and to a lesser extent Array.prototype. I don’t believe Prototype modifies Object.prototype, but I think it does modify Array.prototype. I prefer to not modify array because you can use the somewhat more compact for-in syntax to iterate an array. With the Array.prototype modified you have to use the more standard i