diff options
Diffstat (limited to 'plugins/MirLua/Modules/JSON/src/json.cpp')
-rw-r--r-- | plugins/MirLua/Modules/JSON/src/json.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/MirLua/Modules/JSON/src/json.cpp b/plugins/MirLua/Modules/JSON/src/json.cpp index edfa04fb83..c8680c753c 100644 --- a/plugins/MirLua/Modules/JSON/src/json.cpp +++ b/plugins/MirLua/Modules/JSON/src/json.cpp @@ -3,16 +3,21 @@ static int lua_decode(lua_State *L)
{
const char *string = luaL_checkstring(L, 1);
- MT *udata = (MT*)lua_newuserdata(L, sizeof(MT));
- udata->node = json_parse(string);
- udata->bDelete = true;
+ new (L) MT(json_parse(string));
luaL_setmetatable(L, MT_JSON);
return 1;
}
+int json__call(lua_State *L);
+static int lua_encode(lua_State *L)
+{
+ return json__call(L);
+}
+
static const luaL_Reg methods[] =
{
{ "decode", lua_decode },
+ { "encode", lua_encode },
{ NULL, NULL }
};
|