While I don’t really like ECMAScript 4 for a lot of reasons, the part I really don’t like is including JSON serialization and parsing as part of the core. ECMAScript has never cared about data formats; there’s no native support for XML, why should there be native support for JSON?
Undoubtedly, JSON has been very important to Web 2.0. It is being used everywhere by almost everyone who’s doing anything online. I understand that the popularity requires better tools, but I don’t believe this is the answer. I think the proposal for a
parseJSON() method on the String type is ridiculous – it doesn’t make any sense. The String type isn’t a parser, it’s a string! It shouldn’t have any more functionality than is necessary for dealing with strings. Adding the
Is better support for JSON necessary in browsers? Absolutely. The ability to parse JSON without using
eval() is something that really needs to be provided, but I don’t think what’s in the ECMAScript 4 specification is the answer. I’d rather see one of the browsers take the lead and provide a generic interface that makes sense. Mozilla started the trend of using having DOMParser and XMLHttpRequest…take the lead again and create something for JSON that makes so much sense that the other browsers are forced to implement it too.
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.