Skip to content

Commit

Permalink
luci-lib-jsonc: stringify int use json_object_new_int64 instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lisaac committed Mar 27, 2020
1 parent be36172 commit f0972c8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions libs/luci-lib-jsonc/src/jsonc.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,11 @@ static struct json_object * _lua_to_json_rec(lua_State *L, int index,

case LUA_TNUMBER:
nd = lua_tonumber(L, index);
ni = lua_tointeger(L, index);

if (nd == ni)
return json_object_new_int(nd);

return json_object_new_double(nd);
if(nd >= INT64_MIN && nd <= INT64_MAX)
return json_object_new_int64(nd);
else
return json_object_new_double(nd);

case LUA_TSTRING:
return json_object_new_string(lua_tostring(L, index));
Expand Down

0 comments on commit f0972c8

Please sign in to comment.