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

Function jsonToVariant

app/src/API/Handlers/DataTablesHandler.cpp:53–65  ·  view source on GitHub ↗

* @brief Converts a QJsonValue to a QVariant preserving numeric vs string type. */

Source from the content-addressed store, hash-verified

51 * @brief Converts a QJsonValue to a QVariant preserving numeric vs string type.
52 */
53[[nodiscard]] static QVariant jsonToVariant(const QJsonValue& v)
54{
55 if (v.isDouble())
56 return QVariant(SerialStudio::toDouble(v));
57
58 if (v.isBool())
59 return QVariant(v.toBool() ? 1.0 : 0.0);
60
61 if (v.isString())
62 return QVariant(v.toString());
63
64 return QVariant(0.0);
65}
66
67//--------------------------------------------------------------------------------------------------
68// Command registration

Callers 4

registerAddMethod · 0.85
registerUpdateMethod · 0.85
valueSetMethod · 0.85
valueSetHMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected