MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / jsonArrayToLua

Function jsonArrayToLua

app/src/DataModel/Scripting/ScriptApiCall.cpp:371–382  ·  view source on GitHub ↗

* @brief Pushes a QJsonArray onto the Lua stack as a 1-indexed sequence. */

Source from the content-addressed store, hash-verified

369 * @brief Pushes a QJsonArray onto the Lua stack as a 1-indexed sequence.
370 */
371static void jsonArrayToLua(lua_State* L, const QJsonArray& arr, int depth)
372{
373 lua_createtable(L, arr.size(), 0);
374 if (depth >= kMaxJsonDepth)
375 return;
376
377 int i = 1;
378 for (const auto& v : arr) {
379 jsonValueToLua(L, v, depth + 1);
380 lua_rawseti(L, -2, i++);
381 }
382}
383
384/**
385 * @brief Pushes any QJsonValue onto the Lua stack; null becomes nil.

Callers 1

jsonValueToLuaFunction · 0.85

Calls 4

lua_createtableFunction · 0.85
jsonValueToLuaFunction · 0.85
lua_rawsetiFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected