Answers for "Do not know how to serialize a BigInt"

0

Do not know how to serialize a BigInt

function toJson(data) {
    return JSON.stringify(data, (_, v) => typeof v === 'bigint' ? `${v}n` : v)
        .replace(/"(-?\d+)n"/g, (_, a) => a);
}
Posted by: Guest on October-10-2021

Code answers related to "Do not know how to serialize a BigInt"

Code answers related to "Javascript"

Browse Popular Code Answers by Language