MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / luaScalarToJson

Function luaScalarToJson

pj_scripting/src/luau_engine.cpp:162–173  ·  view source on GitHub ↗

Top-of-stack Lua scalar -> JSON (numbers/bools/strings; else null).

Source from the content-addressed store, hash-verified

160
161// Top-of-stack Lua scalar -> JSON (numbers/bools/strings; else null).
162nlohmann::json luaScalarToJson(lua_State* L, int idx) {
163 switch (lua_type(L, idx)) {
164 case LUA_TBOOLEAN:
165 return static_cast<bool>(lua_toboolean(L, idx));
166 case LUA_TNUMBER:
167 return lua_tonumber(L, idx);
168 case LUA_TSTRING:
169 return std::string(lua_tostring(L, idx));
170 default:
171 return nullptr;
172 }
173}
174
175// Render a JSON scalar to a short label (the fallback when an enum option omits
176// `label`): integers without a trailing ".0", others via dump().

Callers 2

readEnumValuesFunction · 0.85
readParametersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected