{"record":{"id":"d6d928d4124bb27f","repo":"zloirock/core-js","slug":"failed-to-parse-number-s-exponent-value-at-i","errorCode":null,"errorMessage":"Failed to parse number's exponent value at: ${i}","messagePattern":"Failed to parse number's exponent value at: (.+?)","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"packages/core-js/modules/es.json.parse.js","lineNumber":218,"sourceCode":"  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) {\n    var source = this.source;\n    for (; i < source.length; i++) if (!exec(regex, at(source, i))) break;\n    return i;\n  },\n  until: function (array, i) {\n    i = this.skip(IS_WHITESPACE, i);\n    var chr = at(this.source, i);","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/zloirock/core-js/blob/84e45fba098dd3a177d5cf2247d06ab8e98d3790/packages/core-js/modules/es.json.parse.js#L200-L236","documentation":"This SyntaxError is thrown by core-js's polyfilled JSON.parse when a number contains an 'e' or 'E' exponent marker but no digits follow it (after an optional sign). JSON requires at least one exponent digit, so inputs like '1e', '2e+' are invalid and parsing stops at the reported index.","triggerScenarios":"JSON.parse on text containing a number with a dangling exponent, e.g. '{\"n\": 1e}', '3E-', '5e+,'; caused by truncation or by string-building code that appends 'e' + possibly-empty variable.","commonSituations":"Truncated scientific-notation output from logs or streams; constructing payloads with `\"v\": ${mantissa}e${exp}` where exp is empty/undefined; hand-edited data files; legacy engines running the core-js JSON.parse polyfill.","solutions":["Fix the source so the exponent marker is always followed by digits ('1e' -> '1e0', '3E-' -> '3E-1') or remove the marker","Validate numeric strings with a regex like /^-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?$/ before embedding them in JSON","Build payloads with JSON.stringify on real numbers instead of manual string templates","Use the reported index to find and inspect the malformed token in the payload","Wrap JSON.parse in try/catch to convert the SyntaxError into an application-level parse failure with context"],"exampleFix":"// before\nJSON.parse('{\"n\": 1e}'); // SyntaxError: Failed to parse number's exponent value at: 9\n// after\nJSON.parse('{\"n\": 1e0}');","handlingStrategy":"validation","validationCode":"// validate exponent-bearing numeric strings before use\nfunction isValidExponent(numStr) {\n  return /^[+-]?\\d+(\\.\\d+)?([eE][+-]?\\d+)?$/.test(numStr) && !/[eE][+-]?$/.test(numStr);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return JSON.parse(input);\n} catch (e) {\n  if (e instanceof SyntaxError && /exponent value/.test(e.message)) {\n    throw new Error('JSON number has exponent marker without digits: ' + e.message);\n  }\n  throw e;\n}","preventionTips":["Ensure exponent variables are never empty/undefined in templates: `${m}e${Number(exp) || 0}`","Validate numeric strings against the JSON number grammar before embedding","Guard against truncation of scientific-notation output","Prefer JSON.stringify for all numeric serialization"],"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"}