Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BCD for JSON.parse with source context #22800

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

barthy-koeln
Copy link
Contributor

Summary

Added browser compat data for JSON.parse() and a reviver that expects a third argument context, containing the parsed source text.

Test results and supporting details

Quick Test to check if a browser supports the context param:

function testJSONParseWithSource() {
  const unsafeInt = (BigInt(Number.MAX_SAFE_INTEGER) + 1n);

  try {
    const parsedInt = JSON.parse(unsafeInt.toString(10), function (key, value, context) {
      return BigInt(context.source);
    });

    console.info({ parsedInt })
    console.info('Is supported: %s', parsedInt === unsafeInt)
  } catch (error) {
    console.error(error)
    console.info('Is supported: false')
  }
}
Spec

tc39.es proposal | Spec | parse
tc39.es proposal | GitHub

Implementation | Chrome

Chromium Ticket
Related Chromium Commits

Landed as "dev trial" in V8 version 10.8
Landed as "default on" flag in V8 version 11.4

chromestatus.com

Implementation | Firefox

Bugzilla Ticket (open)

Implementation | Safari

WebKit Ticket (open)

Related issues

Relates to #22766

@github-actions github-actions bot added the data:js 📟 Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript label Apr 8, 2024
Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 👍

@Elchi3 Elchi3 merged commit e8ab3ea into mdn:main Apr 16, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:js 📟 Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants