From ac0ca480f5a8598648004b9bd0205a3d7c12e48a Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Wed, 3 Feb 2016 12:03:36 +0000 Subject: MirLua: json encoding support git-svn-id: http://svn.miranda-ng.org/main/trunk@16218 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/Modules/JSON/src/json.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'plugins/MirLua/Modules/JSON/src/json.cpp') 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 } }; -- cgit v1.2.3