JSON decoding

Brendan Eich brendan at mozilla.com
Tue Oct 24 19:40:53 PDT 2006


On Oct 24, 2006, at 7:09 PM, Bob Ippolito wrote:

> On 10/24/06, zwetan <zwetan at gmail.com> wrote:
>> quick pseudo example:
>>
>> Date.prototype.toJSONString
>> return something as "new Date( 2006, 9, 24, ... )"
>>
>> String.prototype.parseJSON
>> should be able to scan the incoming string
>> something as "{ a: new Date(2006, 9, 24), b:new Date( 2006, 11,  
>> 25 ), etc. }"
>> to reckonize "new" keyword
>> then "Date" keyword, then scan open/close parenthesis
>> then dynamically create an instance of the Date object
>> (thanks to the .call/.apply function)
>>
>> I would prefer to use the hook but I suppose using
>> a "new class(...) " notation inside a JSON string
>> will yeld an EncodingError.
>
> This is exactly why toJSONString shouldn't be the API, it should deal
> in objects instead... toJSONString guarantees that the
> interoperability we currently enjoy will vanish.

What exactly is the difference between a function that can be wrapped/ 
overridden (or class that can be subclassed) and a method that can be  
overridden?  Can you show an example of how this breaks?  Sorry if  
this is obvious.

/be




More information about the Es4-discuss mailing list