File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -344,13 +344,16 @@ function parseJSONWithBigInt(str) {
344344 // For older Node.js versions, preprocess the JSON string to convert
345345 // large integers (outside the safe integer range) to strings before parsing.
346346 // This replaces the functionality of json-bigint package.
347+ // The regex matches integers after: colon (:), comma (,), or open bracket ([)
347348 const processed = str . replace (
348- / : \s * ( - ? \d + ) (? = \s * [ , } \] ] ) / g,
349+ / (?: [: , \[ ] ) \s * ( - ? \d + ) (? = \s * [ , } \] ] ) / g,
349350 ( match , number ) => {
350351 const num = Number ( number ) ;
351352 // If the number is not safe, keep it as a string
352353 if ( ! Number . isSafeInteger ( num ) ) {
353- return `: "${ number } "` ;
354+ // Preserve the prefix character (: or , or [)
355+ const prefix = match . charAt ( 0 ) ;
356+ return `${ prefix } "${ number } "` ;
354357 }
355358 return match ;
356359 }
You can’t perform that action at this time.
0 commit comments