blob: c8680c753c9ed31b31698708613915cb4f1849c2 (
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
29
30
31
32
33
 | #include  "stdafx.h"
static int lua_decode(lua_State *L)
{
	const char *string = luaL_checkstring(L, 1);
	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 }
};
LUA_LIBRARY_EXPORT(json)
{
	luaL_newlib(L, methods);
	luaL_newmetatable(L, MT_JSON);
	luaL_setfuncs(L, jsonApi, 0);
	lua_pop(L, 1);
	return 1;
}
 |