Skip to content

Implement proposal-json-parse-with-source API #185

Open

Description

@nevcos

The reviver function receives only the already converted value, which could be inconvenient if the convertion is not being done correctly by the parser.

For example, if a nunber is greater than Number.MAX_SAFE_INTEGER then the convertion will not be OK:

JSON.parse(`{"n":900719925474099123}`, function (k, v) {
  // v will be 900719925474099100 instead of 900719925474099123
  console.log(v);
})

By adding an extra string argument, will give the programmer a way to do the convertion on their own:

JSON.parse(`{"n":900719925474099123}`, function (k, v, raw) {
  return BigInt(raw);
})

Thanks

Activity

  1. jordanbtucker commented on Sep 18, 2018

    @jordanbtucker
    Member

    You make a good point. I can see how this would be a useful extension to the API.

  2. jordanbtucker commented on Oct 3, 2018

    @jordanbtucker
    Member
  3. jordanbtucker commented on Apr 28, 2020

    @jordanbtucker
    Member

    Thanks for the suggestions. While I like your ideas, I don't plan on adding any more features to the JSON5 parser at this time. In an effort to keep JSON5 simple, this library will be a reference parser rather than a full-featured, production-ready implementation of a JSON5 parser.

  4. jordanbtucker commented on May 29, 2022

    @jordanbtucker
    Member

    I'm reopening this issue to track and discuss https://github.com/tc39/proposal-json-parse-with-source since it has gained some traction lately.

    I will not be implementing any of the features from proposal-json-parse-with-source unless and until it gets to stage 4 of the TC39 process.

  5. changed the title [-]Add a new argument to reviver with the original string representation[/-] [+]Implement proposal-json-parse-with-source API[/+] on May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions