blob: edfa04fb83872aa75bf461f4759fc7edb989f869 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include "stdafx.h"
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;
luaL_setmetatable(L, MT_JSON);
return 1;
}
static const luaL_Reg methods[] =
{
{ "decode", lua_decode },
{ NULL, NULL }
};
LUA_LIBRARY_EXPORT(json)
{
luaL_newlib(L, methods);
luaL_newmetatable(L, MT_JSON);
luaL_setfuncs(L, jsonApi, 0);
lua_pop(L, 1);
return 1;
}
|