summaryrefslogtreecommitdiff
path: root/plugins/MirLua/Modules/m_json/src/metatable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua/Modules/m_json/src/metatable.cpp')
-rw-r--r--plugins/MirLua/Modules/m_json/src/metatable.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/MirLua/Modules/m_json/src/metatable.cpp b/plugins/MirLua/Modules/m_json/src/metatable.cpp
index b7b1c37f24..5ea9697d69 100644
--- a/plugins/MirLua/Modules/m_json/src/metatable.cpp
+++ b/plugins/MirLua/Modules/m_json/src/metatable.cpp
@@ -2,8 +2,6 @@
void lua2json(lua_State *L, JSONNode &node)
{
- const char *name = lua_tostring(L, -2);
-
switch (lua_type(L, -1))
{
case LUA_TNIL:
@@ -21,8 +19,6 @@ void lua2json(lua_State *L, JSONNode &node)
case LUA_TTABLE:
{
node.cast(JSON_NODE);
- if (name)
- node.set_name(name);
lua_pushnil(L);
while (lua_next(L, -2) != 0)
@@ -35,6 +31,10 @@ void lua2json(lua_State *L, JSONNode &node)
}
}
}
+
+ const char *name = lua_tostring(L, -2);
+ if (name)
+ node.set_name(name);
}
static int json__index(lua_State *L)