MCPcopy Create free account
hub / github.com/Tencent/UnLua / json_decode

Function json_decode

Plugins/UnLuaExtensions/LuaRapidjson/Source/src/rapidjson.cpp:91–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91static int json_decode(lua_State* L)
92{
93 size_t len = 0;
94 const char* contents = nullptr;
95 switch(lua_type(L, 1)) {
96 case LUA_TSTRING:
97 contents = luaL_checklstring(L, 1, &len);
98 break;
99 case LUA_TLIGHTUSERDATA:
100 contents = reinterpret_cast<const char*>(lua_touserdata(L, 1));
101 len = luaL_checkinteger(L, 2);
102 break;
103 default:
104 return luaL_argerror(L, 1, "required string or lightuserdata (points to a memory of a string)");
105 }
106
107 rapidjson::extend::StringStream s(contents, len);
108 return values::pushDecoded(L, s);
109}
110
111
112

Callers

nothing calls this directly

Calls 6

lua_typeFunction · 0.85
luaL_checklstringFunction · 0.85
lua_touserdataFunction · 0.85
luaL_checkintegerFunction · 0.85
luaL_argerrorFunction · 0.85
pushDecodedFunction · 0.85

Tested by

no test coverage detected