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

stringify null object #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

stringify null object #125

wants to merge 1 commit into from

Conversation

krlosMata
Copy link
Contributor

  • handle null object in stringifyBigInts utils

@krlosMata krlosMata requested a review from jbaylina October 2, 2023 09:09
Copy link
Contributor

@phated phated left a comment

Choose a reason for hiding this comment

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

I don't think we should guard against invalid user input being passed to this function.

@krlosMata
Copy link
Contributor Author

The aim of the PR is not to protect against an invalid input, but to handle correctly the null in JS.
JS interprets null as an object:

> typeof null
`object`

Therefore, the stringifyBigInts makes another recursion to call itself with null and the function breaks.
Hence, null needs to be handle differently.

I understand the stringifyBigInts as an utility to convert any object that contains bigInts into the same object, but the bigInts converted as strings, an object ready to be converted to a JSON file via JSON.stringify().
In the current approachm if that input object a null, the function breaks. While the JSON.stringify() works well with null

@krlosMata krlosMata requested a review from phated December 21, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants