JSON.stringify duplicate whitelist keys

Christian Plesner Hansen christian.plesner.hansen at gmail.com
Mon Aug 17 13:05:32 PDT 2009


I think this is important enough to fix.  I'm slightly in favor of
using the first occurrence but don't feel strongly about it.  Besides
the cons Allen mentioned I'd add that the spec doesn't define an error
type that would be appropriate to throw -- throwing a TypeError seems
pretty arbitrary -- and I agree with Luke that throwing probably won't
be very helpful in practice.


-- Christian

On Mon, Aug 17, 2009 at 9:16 PM, Luke Smith<lsmith at lucassmith.name> wrote:
> Highly dynamic pages could assemble the whitelist from disparate sections of
> code.  Though it is recommended practice to wrap JSON.stringify in a
> try/catch for cyclical ref protection, I don't see a throw here as being
> particularly helpful to developers.  I would prefer that whitelist
> duplicates just be ignored (ignore the second and subsequent).
>
> Just my two cents.
> L
>
> On Aug 17, 2009, at 11:41 AM, Rob Sayre wrote:
>
>> On 8/17/09 2:34 PM, Douglas Crockford wrote:
>>>
>>> Having only one occurence of a key in an object is an important
>>> invariant. So #1 this is important enough to fix.
>>>
>>> I don't care how we achieve the invariant. I'm ok with throwing. I'm ok
>>> with replacing the first value. I'm ok with ignoring the second value.
>>
>> I agree with Doug.
>>
>> We should fix it. Mozilla can get this into an update.
>>
>> - Rob
>
>


More information about the es5-discuss mailing list