go data_error ai_generated true

json: cannot unmarshal number 1e+1000 into Go value of type int

ID: go/json-number-overflow

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-11-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.12 active

Root Cause

JSON中的数字超出目标Go类型的范围

generic

中文

JSON中的数字超出目标Go类型的范围

Workarounds

  1. 90% success
    使用json.Number类型
  2. 85% success
    自定义UnmarshalJSON方法

Dead Ends

Common approaches that don't work:

  1. 60% fail

    精度丢失

  2. 70% fail

    仍然溢出