openresty/lua-cjson

maximum encode_number_precision value

rexxar-liang opened this issue · 3 comments

for the latest code, I found the maximum value of encode_number_precision is 16, which is merged in commit.
f79aa68

For our scenes, we use int64 value in json strings, which means 16 precission numbers is not enough for us.

So any suggestions?
Can we change max value of encode_number_precision to 19, 20 or add new configuration like cjson.max_encode_number_precision(X) for different scenes?

Thanks.

From here, it seems the lua_cjson only support double type, and do not support int64 or uint64.
https://github.com/openresty/lua-cjson/blob/master/lua_cjson.c#L662
image

Do we have any plan to support larger number?
the lua_number in lua5.4 can be long double.
image

Sample problem here.
We are using Long type in java, and cjson cannot decode it correctly

wanrui commented

因为luajit number 类型不能表示int64,可以使用字符串进行处理