bug: issues with numerical precision
- Dominant language
- Lua
- Stars
- 17.1k
- Forks
- 2.9k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 63
Description
### Current Behavior
local core = require("apisix.core")
local redis = require("resty.redis")
return function(conf, ctx)
core.log.error("=====post===", tostring(ctx.conf_version), "===")
local result = "{ \"aaa\" : 9007199263392129 }"
local aaaa = core.json.decode(result)
core.log.error("=====aaaaaaaaaaaa===", tostring(aaaa.aaa), "===")
--设置返回
ngx.arg[1] = core.json.encode({aaa=aaaa.aaa})
ngx.arg[2] = true
return
end 数据精度问题 9007199263392129这个会返回 {"aaa":9007199263392128} 请问有什么办法可以处理高精度问题 如java 那种long类型的数字
### Expected Behavior
可以处理高精度问题 如java 那种long类型的数字
### Error Logs
{"aaa":9007199263392128} 精度丢失
### Steps to Reproduce
apisix3.14.1
### Environment
- APISIX version (run `apisix version`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
Contributor guide
Research direction
Start by reproducing the reported behavior in APISIX 3.14.1 with the shown core.json decode and encode calls and the value 9007199263392129. Trace the core.json entry points to determine where precision is lost, then identify the project’s existing JSON-related tests or test entry points. Done means the expected handling of high-precision numeric values is defined and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100