summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MirLua/Modules/m_json/m_json.vcxproj2
-rw-r--r--plugins/MirLua/Modules/m_json/src/main.cpp8
-rw-r--r--plugins/MirLua/Modules/m_json/src/metatable.cpp8
3 files changed, 8 insertions, 10 deletions
diff --git a/plugins/MirLua/Modules/m_json/m_json.vcxproj b/plugins/MirLua/Modules/m_json/m_json.vcxproj
index 538ed63f5c..a16b5b743e 100644
--- a/plugins/MirLua/Modules/m_json/m_json.vcxproj
+++ b/plugins/MirLua/Modules/m_json/m_json.vcxproj
@@ -20,7 +20,7 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>m_json</ProjectName>
- <ProjectGuid>{8A645067-7F45-4E65-AAFC-AFDA81C29A1D}</ProjectGuid>
+ <ProjectGuid>{99712BCA-F86F-4214-967D-1298DF0F4A13}</ProjectGuid>
</PropertyGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\module.props" />
diff --git a/plugins/MirLua/Modules/m_json/src/main.cpp b/plugins/MirLua/Modules/m_json/src/main.cpp
index fe987d36f3..c26f350f63 100644
--- a/plugins/MirLua/Modules/m_json/src/main.cpp
+++ b/plugins/MirLua/Modules/m_json/src/main.cpp
@@ -17,11 +17,9 @@ static int lua_Encode(lua_State *L)
JSONNode *node = json_new(JSON_NODE);
lua_pushnil(L);
- while (lua_next(L, 1) != 0)
- {
- lua2json(L, *node);
- lua_pop(L, 1);
- }
+ lua_pushvalue(L, 1);
+ lua2json(L, *node);
+ lua_pop(L, 2);
JSON *mt = new (L) JSON(node);
luaL_setmetatable(L, MT_JSON);
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)