satoren / LRDB

Lua Remote DeBugger
Boost Software License 1.0
62 stars 21 forks source link

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

Open xiayong968 opened 4 years ago

xiayong968 commented 4 years ago

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


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

satoren commented 4 years ago

That is bug same to #12.

xiayong968 commented 4 years ago

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
    }