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

The "key" parameter passed to replacer is of number type for array elements #42

Closed
james-hu opened this issue Mar 19, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@james-hu
Copy link

Try this code with both JSON.stringify and safe-stable-stringify:

const keys: Array<any> = [];
JSON.stringify(['a', 'b'], function (key: any, value: any) {
  keys.push(key);
  return value;
});
console.log(jsonStringifyKeys);

And then you will find that JSON.stringify passes strings "0" and "1" to the replacer function, while safe-stable-stringify passes numbers 0 and 1.

@BridgeAR BridgeAR added the bug Something isn't working label Mar 19, 2023
@BridgeAR
Copy link
Owner

Thanks for the report @james-hu! This is fixed in 2.4.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants