fix JSON status bool

This commit is contained in:
Syping 2024-05-09 21:59:57 +02:00
parent 6595738d64
commit 0198da6595

View file

@ -164,7 +164,7 @@ bool SMSubServer::messageReceived(QObject *socket, const QByteArray &message)
#ifdef BOOST_JSON
boost::json::object object;
object["type"] = "status";
object["status"] = status ? "on" : "off";
object["status"] = status;
object["start"] = startTime;
object["stop"] = stopTime;
const std::string json = boost::json::serialize(object) + '\n';
@ -172,7 +172,7 @@ bool SMSubServer::messageReceived(QObject *socket, const QByteArray &message)
#else
QJsonObject object;
object["type"] = "status";
object["status"] = status ? "on" : "off";
object["status"] = status;
object["start"] = startTime;
object["stop"] = stopTime;
sendMessage(socket, QJsonDocument(object).toJson(QJsonDocument::Compact) + '\n');
@ -371,14 +371,14 @@ void SMSubServer::statusUpdated(const bool status_, const qint64 time)
#ifdef BOOST_JSON
boost::json::object object;
object["type"] = "status";
object["status"] = status ? "on" : "off";
object["status"] = status;
object["start"] = startTime;
object["stop"] = stopTime;
json_output = QByteArray::fromStdString(boost::json::serialize(object) + '\n');
#else
QJsonObject object;
object["type"] = "status";
object["status"] = status ? "on" : "off";
object["status"] = status;
object["start"] = startTime;
object["stop"] = stopTime;
json_output = QJsonDocument(object).toJson(QJsonDocument::Compact) + '\n';