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