LRDB icon indicating copy to clipboard operation
LRDB copied to clipboard

if table has integer key,when break, show empty table

Open xiayong968 opened this issue 4 years ago • 2 comments

local t = {} t[1000] = "hi"


when break the script,the table t show empty,is it a bug?

xiayong968 avatar Jun 15 '20 03:06 xiayong968

That is bug same to #12.

satoren avatar Jun 15 '20 12:06 satoren

i fix it :)

    json::object obj;
    lua_pushnil(L);
    while (lua_next(L, index) != 0) {
      if (lua_type(L, -2) == LUA_TSTRING) {
        const char* key = lua_tostring(L, -2);
        json::value& b = obj[key];
        b = to_json(L, -1, max_recursive - 1);
      } else if (lua_type(L, -2) == LUA_TNUMBER) {
         const char* key = "";
     if (lua_isinteger(L,-2)){
              lua_Integer temp = lua_tointeger(L, -2);	
	  key = int64_to_string(temp);
      }	else{
	   double temp = lua_tonumber(L, -2);
	   key = double_to_string(temp);
	}
            json::value& b = obj[key];
            b = to_json(L, -1, max_recursive - 1);
        }
        lua_pop(L, 1);  // pop value
    }

xiayong968 avatar Jun 18 '20 02:06 xiayong968