go data_error ai_generated true

json: 无法将数字1e+1000解析为int类型

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

ID: go/json-number-overflow

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2024-11-01首次发现

版本兼容性

版本状态引入弃用备注
1.12 active

根因分析

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

English

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

generic

解决方案

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

无效尝试

常见但无效的做法:

  1. 60% 失败

    精度丢失

  2. 70% 失败

    仍然溢出