Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"integer" JSON value become float in lua5.3 #91

Open
dong-king opened this issue Apr 4, 2023 · 1 comment
Open

"integer" JSON value become float in lua5.3 #91

dong-king opened this issue Apr 4, 2023 · 1 comment

Comments

@dong-king
Copy link

environment: lua5.3 and lua-cjson 2.1.0.10-1

json file: cfg.json

{
    "server_ip": "192.168.1.100",
    "server_port": 10000,
}

lua code:

local cjson = require("cjson.safe")
local cfg_file_path = './cfg.json'

local cfg_fd = io.open(cfg_file_path, 'r')
local cfg_contents = cfg_fd:read("*all")
local cfg_obj = cjson.decode(cfg_contents)

for key, value in pairs(cfg_obj) do
    print(value)
end

the printout result:
192.168.1.100
10000.0

@LitschiW
Copy link

LitschiW commented Jun 6, 2023

We have a similar problem using cjson to process an opentelemetry request after decoding and encodind.

Input: "timeUnixNano":1686041011364000000
Output: "timeUnixNano":1.686041011364e+18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants