openresty / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua
http://www.kyne.com.au/~mark/software/lua-cjson.php
MIT License
436 stars 119 forks source link

maximum encode_number_precision value #80

Open rexxar-liang opened 2 years ago

rexxar-liang commented 2 years ago

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 commented 2 years ago

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

kevinw66 commented 2 years ago

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

wanrui commented 1 year ago

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