want to parse json in javascript and it has numbers larger than Number.MAX_SAFE_INTEGER?
well, you just simply,<code>const isBigNumber = num => !Number.isSafeInteger(+num)<br><br>const enquoteBigNumber = (jsonString, bigNumChecker) =><br> jsonString<br> .replaceAll(<br> /([:\s\[,]*)(\d+)([\s,\]]*)/g,<br> (matchingSubstr, prefix, bigNum, suffix) =><br> bigNumChecker(bigNum)<br> ? `${prefix}"${bigNum}"${suffix}`<br> : matchingSubstr<br> )<br><br>const parseWithBigInt = (jsonString, bigNumChecker) =><br> JSON.parse(<br> enquoteBigNumber(jsonString, bigNumChecker),<br> (key, value) =><br> !isNaN(value) && bigNumChecker(value)<br> ? BigInt(value)<br> : value<br> )<br><br>const output = parseWithBigInt(input, isBigNumber)<br></code>