Skip to content

Commit 7505449

Browse files
committed
switch from parseFloat to Number
1 parent 0eaf189 commit 7505449

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/impl/parser.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -483,18 +483,11 @@ export function visit(text: string, visitor: JSONVisitor, options: ParseOptions
483483
switch (_scanner.getToken()) {
484484
case SyntaxKind.NumericLiteral:
485485
const tokenValue = _scanner.getTokenValue();
486-
let value = parseFloat(tokenValue);
486+
let value = Number(tokenValue);
487487

488488
if (isNaN(value)) {
489-
try {
490-
value = JSON.parse(tokenValue);
491-
if (typeof value !== 'number') {
492-
handleError(ParseErrorCode.InvalidNumberFormat);
493-
value = 0;
494-
}
495-
} catch (e) {
496-
handleError(ParseErrorCode.InvalidNumberFormat);
497-
}
489+
handleError(ParseErrorCode.InvalidNumberFormat);
490+
value = 0;
498491
}
499492

500493
onLiteralValue(value);

0 commit comments

Comments
 (0)