Skip to content

encode_number_precision

json.encode_number_precision(precision)

The amount of significant digits returned by json.stringify() when encoding numbers can be changed to balance accuracy versus performance. For data structures containing many numbers, setting json.encode_number_precision to a smaller integer, for example 3, can improve encoding performance by up to 50%. By default, Lua CJSON will output 14 significant digits when converting a number to text.