> FWIW JS does not have a similar capability so I can't add a note there
This example on MDN seems to indicate that you can, am I misunderstanding it?
const bigJSON = '{"gross_gdp": 12345678901234567890}';
const bigObj = JSON.parse(bigJSON, (key, value, context) => {
if (key === "gross_gdp") {
// Ignore the value because it has already lost precision
return BigInt(context.source);
}
return value;
});
The optional `context` parameter is a tc39 proposal. The feature compatibility matrix on the bottom of the MDN page is really confusing because it's showing only when `JSON.parse` was added, not whether the optional `context` parameter is supported.
This example on MDN seems to indicate that you can, am I misunderstanding it?
[0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...