Skip to content

Should __proto__ property be treated specially? #199

Description

@LongTengDao

The json5-spec didn't mention it.

JSON5.parse('{__proto__:1}').__proto__ // not 1

I know it's in js-spec, I just wonder whether it should be same like js.

({__proto__:1}).__proto__ // not 1

Because in JSON land, __proto__ key is just a normal key, as a data language.

JSON.parse('{"__proto__":1}').__proto__ // is 1

BTW: Is it right for JSON5 parser use [[set]] not [[define]]?

Object.defineProperty(Object.prototype, 'xxx', { set (value) { console.log('setting!'); } });
JSON5.parse('{xxx:1}');// setting!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions