Skip to content

Conversation

@ntwl-xyz
Copy link

I ran into issues using https://github.com/trentm/node-bunyan which makes use of this library.

This PR simply converts BigInts to strings, which I think is reasonable because

> BigInt('11111111111111111111111111111111111');
11111111111111111111111111111111111n

BigNumber.js similarly uses strings as an intermediate representation.

I ran into issues using https://github.com/trentm/node-bunyan which makes use of this library.

This PR simply converts BigInts to strings, which I think is reasonable because 
```
> BigInt('11111111111111111111111111111111111');
11111111111111111111111111111111111n
```

BigNumber.js similarly uses strings as an intermediate representation.
@TwitchBronBron
Copy link

Any chance this could get merged and released soon?

@TwitchBronBron
Copy link

For those who are interested, I worked around this issue in rokucommunity/logger#3 by using the replacer 2nd argument.

const safeJsonStringify = require('safe-json-stringify');
const theObjectToStringify = {
    someBigInt: BigInt('123')
};
const jsonString = safeJsonStringify(theObjectToStringify, (key, value) => {
    //if it's a BigInt, return the string value instead
    return typeof value === 'bigint' ? value.toString() : value;
});

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