FW: JSON.stringify replacer array semantics

David-Sarah Hopwood david-sarah at jacaranda.org
Tue Jun 9 19:55:25 PDT 2009


Allen Wirfs-Brock wrote:
> Still looking for some consensus on the issue at the end of Doug's message...
> 
>>> 2) should ToString be applied to the elements of an replacer array?
>>> Currently this is not done in the ES5 spec.  Oliver reports that FF
>>> 3.5 does this. IE8 does not.  json2.js does not.  Is this a reasonable
>>> departure from the json2.js implementation?
>>
>> It seems like an unnecessary step to me. Perhaps it would be better to
>> throw?
> 
> Throwing seems inconsistence with all the other rounded corners and outlet
> protectors that we provide in this function.  I think that the two plausible
> alternatives are to either ignore non-string whitelist values (this is what
> IE8 and json2.js currently do) or to apply ToString to each whitelist value
> (which is apparently what FF3.5 does) 

Applying ToString would do what the programmer probably intended in the
case of number values.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com



More information about the es5-discuss mailing list