| 332 | } |
| 333 | |
| 334 | static int json_to_lua(lua_State *L) |
| 335 | { |
| 336 | if (lua_gettop(L) < 1) |
| 337 | return 0; |
| 338 | if (!lua_isstring(L, 1)) |
| 339 | return 0; |
| 340 | auto json_str = luaL_checkstring(L, 1); |
| 341 | thinkyoung::lua::lib::GluaStateScope scope; |
| 342 | auto token_parser = std::make_shared<GluaTokenParser>(scope.L()); |
| 343 | token_parser->parse(std::string(json_str)); |
| 344 | token_parser->reset_position(); |
| 345 | bool result = false; |
| 346 | auto value = tokens_to_lua_value(L, token_parser.get(), &result); |
| 347 | if (!result) |
| 348 | { |
| 349 | return 0; |
| 350 | } |
| 351 | lua_push_storage_value(L, value); |
| 352 | return 1; |
| 353 | } |
| 354 | |
| 355 | static int lua_to_json(lua_State *L) |
| 356 | { |
nothing calls this directly
no test coverage detected