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

Does not retain the decimal places as .0 float #100

Open
zzyy3321 opened this issue Mar 27, 2024 · 1 comment
Open

Does not retain the decimal places as .0 float #100

zzyy3321 opened this issue Mar 27, 2024 · 1 comment

Comments

@zzyy3321
Copy link

Issue Description:
When using the lua cjson library to encode Lua tables containing floating-point numbers with decimal places, the output JSON does not retain the decimal places as expected.

Steps to Reproduce:

local table = {}
table["a"] = 80.00
local j = require "cjson.safe"
local json = j.encode(table)
ngx.say(json)

Expected Output:
The expected JSON output should retain the decimal places for floating-point numbers, for example:

{
    "a": 80.00
}

Actual Output:
The actual JSON output does not retain the decimal places, for example:

{
    "a": 80
}

I have tested this issue using the lua cjson library on openresty and confirmed the behavior described above.

@zzyy3321 zzyy3321 changed the title Does not retain the decimal places as .0. Does not retain the decimal places as .0 float Mar 27, 2024
@zhuizhuhaomeng
Copy link

This doesn't appear to be a problem, as there is no loss of accuracy.

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