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

Implement the optional reviver parameter in JSON.parse( text [, reviver] ) #344

Closed
HalidOdat opened this issue Apr 26, 2020 · 3 comments · Fixed by #410
Closed

Implement the optional reviver parameter in JSON.parse( text [, reviver] ) #344

HalidOdat opened this issue Apr 26, 2020 · 3 comments · Fixed by #410
Assignees
Labels
E-Easy Easy enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@HalidOdat
Copy link
Member

HalidOdat commented Apr 26, 2020

Currently the JSON.parse( text[, reviver] ) method only supports the first parameter which takes in a String and converts into an Object.
But, there is an optional function argument that JSON.parse( text[, reviver] ) method takes. It prescribes how the value originally produced by parsing is transformed, before being returned.

Example:

JSON.parse('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}', (key, value) => {
  console.log(key); // log the current property name, the last is "".
  return value;     // return the unchanged property value.
});

More information:

You can check the Array.prototype.every implementation to see how to deal with JavaScript callback functions.

@HalidOdat HalidOdat added enhancement New feature or request good first issue Good for newcomers E-Easy Easy labels Apr 26, 2020
@abhijeetbhagat
Copy link
Contributor

I can take this. Btw, the link to Array.prototype.every is pointing to the wrong line number. It should be 491.

@Razican
Copy link
Member

Razican commented May 11, 2020

I can take this. Btw, the link to Array.prototype.every is pointing to the wrong line number. It should be 491.

Sure! Go for it :)

I think I fixed the link 😅

@abhijeetbhagat
Copy link
Contributor

Can you please assign it to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-Easy Easy enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants