浏览代码

update: 更新json.encode描述, 默认7f格式化浮点数

Wendal Chen 2 年之前
父节点
当前提交
3c1b922dfb
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      components/lua-cjson/lua_cjson.c

+ 4 - 1
components/lua-cjson/lua_cjson.c

@@ -1396,12 +1396,15 @@ static int json_protect_conversion(lua_State *l)
 将对象序列化为json字符串
 @api json.encode(obj,t)
 @obj 需要序列化的对象
-@string 浮点数精度和模式,这项不存在的时候,为默认值"7g",数字只支持"0~14",模式只支持"f/g"
+@string 浮点数精度和模式,这项不存在的时候,为默认值"7f",数字只支持"0~14",模式只支持"f/g"
 @return string 序列化后的json字符串, 失败的话返回nil
 @return string 序列化失败的报错信息
 @usage
 json.encode(obj)-->浮点数用%.7g的方式转换为字符串
 json.encode(obj,"12f")-->浮点数用%.12f的方式转换为字符串
+
+-- 2024.1.9 起, 默认使用7f格式化浮点数
+-- 之前的版本使用 7g格式化浮动数
 */
 static int l_json_encode_safe(lua_State *L) {
     // int top = lua_gettop(L);