lua-cjson icon indicating copy to clipboard operation
lua-cjson copied to clipboard

maximum encode_number_precision value

Open rexxar-liang opened this issue 3 years ago • 3 comments

for the latest code, I found the maximum value of encode_number_precision is 16, which is merged in commit. openresty@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.

rexxar-liang avatar Dec 24 '21 02:12 rexxar-liang

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

rexxar-liang avatar Dec 27 '21 03:12 rexxar-liang

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

kevinw66 avatar Jan 26 '22 08:01 kevinw66

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

wanrui avatar Nov 16 '23 00:11 wanrui