Skip to content

bug: issues with numerical precision #13280

@chao6118

Description

@chao6118

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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionlabel for questions asked by users

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions