Lars T Hansen
lth at acm.org
Mon Sep 3 02:09:39 PDT 2007
On 9/2/07, Garrett Smith <dhtmlkitchen at gmail.com> wrote:
> I was wondering about the new JSON methods:
> to me, parseJSON seems like it should not be a String prototype method.
> I'm thinking about other "parse" type of methods, like Date.parse( s );
> Here, it's fairly obvious what parse should return -- A Date.
Date.parse() returns a number, not a Date. E262-3 18.104.22.168 first paragraph.
> A parse method always parses a string, and in any well-designed API,
> returns an object of the class it's bound to. We've already seen this
> with Date.parse(), in other languages, like Java, there are
> Integer.parseInt, Double.parseDouble.
> It seems to me to make more sense to put parseJSON on object, but then
> since JSON is a subset of Object, why not just put it as a subclass of
> Object +
> It seems to me, that Object.prototype.toJSONString could be also
> implemented on a JSON instance.
> JSON( object )
> static JSON parse( s ) throws SyntaxError
> JSON.prototype.toString( )
> JSON.prototype.isValid( )
> Programming is a collaborative art.
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
More information about the Es4-discuss