{"record":{"id":"ce7f1173efeb3e30","repo":"zloirock/core-js","slug":"failed-to-parse-number-s-fraction-at-i","errorCode":null,"errorMessage":"Failed to parse number's fraction at: ${i}","messagePattern":"Failed to parse number's fraction at: (.+?)","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"packages/core-js/modules/es.json.parse.js","lineNumber":211,"sourceCode":"    return this.node(OBJECT, array, this.index, i, nodes);\n  },\n  string: function () {\n    var index = this.index;\n    var parsed = parseJSONString(this.source, this.index + 1);\n    return this.node(PRIMITIVE, parsed.value, index, parsed.end);\n  },\n  number: function () {\n    var source = this.source;\n    var startIndex = this.index;\n    var i = startIndex;\n    if (at(source, i) === '-') i++;\n    if (at(source, i) === '0') i++;\n    else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, i + 1);\n    else throw new SyntaxError('Failed to parse number at: ' + i);\n    if (at(source, i) === '.') {\n      var fractionStartIndex = i + 1;\n      i = this.skip(IS_DIGIT, fractionStartIndex);\n      if (fractionStartIndex === i) throw new SyntaxError(\"Failed to parse number's fraction at: \" + i);\n    }\n    if (at(source, i) === 'e' || at(source, i) === 'E') {\n      i++;\n      if (at(source, i) === '+' || at(source, i) === '-') i++;\n      var exponentStartIndex = i;\n      i = this.skip(IS_DIGIT, i);\n      if (exponentStartIndex === i) throw new SyntaxError(\"Failed to parse number's exponent value at: \" + i);\n    }\n    return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i);\n  },\n  keyword: function (value) {\n    var keyword = '' + value;\n    var index = this.index;\n    var endIndex = index + keyword.length;\n    if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index);\n    return this.node(PRIMITIVE, value, index, endIndex);\n  },\n  skip: function (regex, i) {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/zloirock/core-js/blob/84e45fba098dd3a177d5cf2247d06ab8e98d3790/packages/core-js/modules/es.json.parse.js#L193-L229","documentation":"This SyntaxError is thrown by core-js's polyfilled JSON.parse when a JSON number contains a '.' starting a fractional part, but there is no digit immediately after the dot. The JSON grammar requires at least one digit after '.', so inputs like '1.' or '0.e5' are invalid and parsing aborts at the index reported.","triggerScenarios":"JSON.parse on text where a number literal has a trailing or digit-less decimal point, e.g. '{\"x\": 1.}', '1.,', or '2. e3'; typically produced by code generating JSON via string concatenation or by truncated numeric output (toFixed/serialization cut off).","commonSituations":"Truncated log or telemetry lines where the fractional digits were cut off; template-built payloads like `\"price\": ${price}.` ; hand-edited configs; polyfilled JSON.parse on legacy engines surfacing the malformed number.","solutions":["Fix the JSON source so every '.' in a number is followed by at least one digit ('1.' -> '1.0' or '1')","If a trailing dot is intentional, use JSON5 or another lenient parser instead of JSON.parse","Sanitize generated numbers before embedding: Number(x) then JSON.stringify, never manual concatenation","Inspect the index in the error message to locate the malformed number in the input string","Catch the SyntaxError around JSON.parse and report the raw payload for debugging"],"exampleFix":"// before\nJSON.parse('{\"price\": 1.}'); // SyntaxError: Failed to parse number's fraction at: 11\n// after\nJSON.parse('{\"price\": 1.0}');","handlingStrategy":"validation","validationCode":"// reject numbers with a digit-less fraction before embedding in JSON\nfunction hasValidFraction(numStr) {\n  return !/\\.(?![0-9])/.test(numStr);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return JSON.parse(input);\n} catch (e) {\n  if (e instanceof SyntaxError && /number's fraction/.test(e.message)) {\n    console.error('Truncated/dangling decimal point in JSON:', e.message);\n    return null; // or re-request data\n  }\n  throw e;\n}","preventionTips":["Always emit at least one digit after a decimal point ('1.0', not '1.')","Avoid string templates for numbers; pass real numbers to JSON.stringify","Check for truncation when JSON crosses size-limited channels (logs, queues)","Lint generated payloads in CI with a strict JSON parser"],"tags":["json","syntax-error","polyfill","core-js"],"backgroundTag":"invalid-json-syntax","analyzedSha":"84e45fba098dd3a177d5cf2247d06ab8e98d3790","analyzedAt":"2026-08-30T20:36:10.323Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}