__proto__ and JSON

Mark S. Miller erights at google.com
Wed May 30 10:18:42 PDT 2012


On Wed, May 30, 2012 at 7:12 AM, Felix Böhm <esdiscuss at feedic.com> wrote:

>
>
> 2012/5/30 Brendan Eich <brendan at mozilla.com>
>
>> Felix Böhm wrote:
>>
>>> Okay, fair point. But JSON.parse should do what it's name says: Parse
>>> JSON. Ignoring keys is not an option.
>>>
>> JSON.parse must not treat __proto__ specially, per ES5. What's the
>> problem you see?
>
>
> As written before, V8 ignores keys named __proto__ in JSON.parse (I
> haven't tested other engines yet). I was concerned that this behavior would
> become the default.
>

These are filed and accepted bugs in v8:

http://code.google.com/p/v8/issues/detail?id=621
http://code.google.com/p/v8/issues/detail?id=1310

and tested by test262:

http://hg.ecmascript.org/tests/test262/file/c84161250e66/test/suite/ch15/15.12/15.12.2/S15.12.2_A1.js



>
>>
>>  Having __proto__ as a setter would make much more sense for me, too. No
>>> magic involved, just some functionality I don't need to care about.
>>>
>>
>> Please see the thread on "Re: Subclassing built-in constructors", also
>> the meeting notes followups from me. __proto__ has a hidden setter, it
>> masquerades as a data property to avoid leaking a set-[[Prototype]]
>> capability that would require extra checking and could (based on long and
>> hard experience) lead to mischief.
>>
>> The de-facto and soon to be de-jure Object.prototype.__proto__ standard
>> has no bearing on ES5's JSON.parse, which continues unchanged per the JSON
>> RFC (I trust -- tell me if you see a bug).
>>
>> /be
>>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120530/c4f0017e/attachment.html>


More information about the es-discuss mailing list