logoalt Hacker News

sheepttoday at 10:06 AM1 replyview on HN

You can serialize a BigInt by specifying a replacer:

    const obj = { a: 9007199254740993n }
    JSON.stringify(obj, (_key, value) => typeof value === 'bigint' ? JSON.rawJSON(value.toString()) : value)

Replies

mort96today at 10:27 AM

And then you end up with strings on the other side, not numbers.

show 1 reply