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

Function jsonScalarToString

pj_scripting/src/luau_engine.cpp:177–191  ·  view source on GitHub ↗

Render a JSON scalar to a short label (the fallback when an enum option omits `label`): integers without a trailing ".0", others via dump().

Source from the content-addressed store, hash-verified

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().
177std::string jsonScalarToString(const nlohmann::json& j) {
178 if (j.is_string()) {
179 return j.get<std::string>();
180 }
181 if (j.is_number_integer()) {
182 return std::to_string(j.get<std::int64_t>());
183 }
184 if (j.is_boolean()) {
185 return j.get<bool>() ? "true" : "false";
186 }
187 if (j.is_number()) {
188 return std::to_string(j.get<double>());
189 }
190 return {};
191}
192
193void pushJsonScalar(lua_State* L, const nlohmann::json& j) {
194 if (j.is_boolean()) {

Callers 1

readEnumValuesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected